1

Looks like functions which are part of the React framework are referred to as "methods":

"The only method you must define in a React.Component subclass is called render()."

https://reactjs.org/docs/react-component.html

However, this excerpt is from further down in the same webpage:

"The render() function should be pure, meaning that it does not modify component state"

So even in the same webpage on the official React website, render() seems to be referred to as either a function or a method. Do you use any guidelines for using the term "function" vs "method" when discussing these constructs in React? Or in the React world are these two terms completely interchangeable with no real discernment or nuance?

random512
  • 987
  • 1
  • 12
  • 17

3 Answers3

1

Do you use any guidelines for using the term "function" vs "method" when discussing these constructs in React?

No guidelines between referring to them either way because both terms are correct. However, I tend to hear render function more instead of render method from my experience.

It's most preferable for using the term "method" when explicitly mentioning/referring to "Class" or "Object" as in the case of the sentence the React docs used:

The only method you must define in a React.Component subclass is called render()

Still, it's up to preference regardless.


For reference on what a method is from MDN:

A method is a function which is a property of an object

https://developer.mozilla.org/en-US/docs/Glossary/Method

kmui2
  • 1,489
  • 11
  • 16
0

Generally the term "method" is used when describing a function that belongs to an object or class.

To use the term function is always correct, the reason react often uses the term "method" is because in react the code is often running inside of a class.

cd3k
  • 605
  • 3
  • 8
0

See What's the difference between a method and a function?.

In React, we usually talk about "method"s when we want to refer to a function in class component, like lifecycle methods.

Otherwise, it's just a normal function (arrow function included).

Don't get confused between the terms function and function component as they are not the same.

Dennis Vash
  • 42,190
  • 6
  • 81
  • 99