Really dumb question about React Compiler
I figure this is a question someone deeper into the React ecosystem can answer. I've read some of what the React Compiler can do, but I'm not quite grokking it. Does React Compiler simply run through JavaScript and React code and improve its performance? Or can it be used to compile React code in such a way that it can be run standalone? As in, does it compile, optimize, and minify the code in such a way that I can run it on another application without that application running an instance of
react
and react-dom
?5 Replies
Solution
the compiler adds memoization (remove unnecessary rerenders) from react
or at least does the best it can
Ah, okay. So not as deep as what I had in mind. Got it.
That's still definitely useful, I was wondering if it could be used for a common global component used across applications using different frameworks in the same way web components are used.
take a component like this:
it will log something like this, after each click, the same logs will appear
rendered Component1
rendered Component1
rendered Component2
rendered Component2
rendered Component3
rendered Component3
the same exact react code, after the compiler
------------------
rendered Component1
rendered Component2
rendered Component3
:click:
rendered Component1
rendered Component2
---------------
nothing added, and its already faster
you code reduce the rerendering by changing
now only component 1 will rerender after the click