.render() method in React

codecademy.com/paths/web-development/tracks/front-end-applications-with-react/modules/react-101-react-components-u/lessons/your-first-react-component/exercises/render-function
Hello! I have a question about .render() method.
A render method is a property whose name is render , and whose value is a function.
How can I understand “value of the render method is a function”? And why render method here called as render function if its a method? Also I wanted to ask why do we use “return” in the method?
Thank you in advance

the MDN documentation:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects#Defining_methods

formulates it better:

A method is a function associated with an object, or, simply put, a method is a property of an object that is a function.

Methods are also properties.

You have learned JS before starting reactJS, right? Well, we need to return what we want to render on the page.

Actually I always used console.log() in methods, so thats why I asked about using return in methods) I usually use return in functions and conole.log() in methods, so thats why I was confused

.log() logs something to the console.

return hands back data to the caller.

given the log method and return keyword achieve very different things, they are not interchangeable.

1 Like