facebook / react

The library for web and native user interfaces.
https://react.dev
MIT License
227.92k stars 46.52k forks source link

Rendering via JSX vs function call #12066

Closed riwu closed 6 years ago

riwu commented 6 years ago

From https://medium.com/missive-app/45-faster-react-functional-components-now-3509a668e69f, rendering via {Component(props)} is significantly faster than <Component {...props} />.

Is there any plans in the near future (within the next few months perhaps) to optimise functional components so that we do not have to perform this optimisation (avoiding JSX for non-html elements)?

gaearon commented 6 years ago

We're looking at optimizations like this in the context of Prepack but there's nothing that's going to be immediately useable in the next couple of months. Within a year or two we might have something.

Note that unless you're creating thousands of elements, the performance difference won't be noticeable. Also unless your components are very flat and simple, the "pure win" from this optimization will likely be much less relevant in practice.