4 ms·
React doesn't do any "compiling". It simply takes the JS object tree that _you_ generated in your component's render function, and works from there. So yes, i
by acemarke 9y ago
React doesn't do any "compiling". It simply takes the JS object tree that _you_ generated in your component's render function, and works from there. So yes, if you are declaring object literals in your render method, that will be a new object each time the component re-renders.
If you know that a given style object is never going to change, you can hoist it out of your component's render method into the module scope yourself.
- tarr11 9y agoThis babel preset might do it. I haven't tried but it looks promising... https://babeljs.io/docs/plugins/transform-react-constant-elements/ https://babeljs.io/docs/plugins/transform-react-constant-ele...