Greeting component which is defined as a function:
React also supports defining it as a class:
When you want to render a
<Greeting />, you don’t care how it’s defined:
But React itself cares about the difference!
Greeting is a function, React needs to call it:
Greeting is a class, React needs to instantiate it with the
new operator and then call the
render method on the just created instance:
In both cases React’s goal is to get the rendered node (in this example,
<p>Hello</p>). But the exact steps depend on how
Greeting is defined.
So how does React know if something is a class or a function?
... read the whole story at overreacted.io.