Hacker News new | ask | show | jobs
by acemarke 3227 days 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.

1 comments

This babel preset might do it. I haven't tried but it looks promising...

https://babeljs.io/docs/plugins/transform-react-constant-ele...