Description
The current documentation says:
The simplest way to define a component is to write a JavaScript function:
[...]
You can also use an ES6 class to define a component:
[...]
The above two components are equivalent from React’s point of view.
I just encountered a contradictory comment from @trueadm, an engineer on the React core team:
In React 16, functional components are quite a bit faster than class components. On a side note, this optimization is something we’re aware of and have been talking about a bit recently. :)
Does this mean that the possible future optimizations for functional components that were mentioned in previous versions of the docs and blog posts have now been implemented? If so, this should be mentioned in the docs (and probably should have been in the release notes for React 16 too, but I don't see it mentioned there).
If this has indeed been implemented, then it should also be noted that this is a micro-optimization that still pales in comparison with using PureComponent (or your own efficient shouldComponentUpdate()
logic), as explained in facebook/react#5677 (comment):
For complex components, defining
shouldComponentUpdate
(eg. pure render) will generally exceed the performance benefits of stateless components. The sentences in the docs are hinting at some future optimizations that we have planned, whereby we won't allocate an internal instance for stateless functional components (we will just call the function). We also might not keep holding the props, etc. Tiny optimizations. We don't talk about the details in the docs because the optimizations aren't actually implemented yet (stateless components open the doors to these optimizations).