Switching on the React Compiler in MatterSuite
I fixed the Hooks problems behind extra re-renders, then introduced the React Compiler. The app now re-renders far less.
Situation
MatterSuite re-rendered far more than it needed to, and some modules felt slow. The code was good, but some components broke the Rules of Hooks, including the order of hooks, which made behavior unpredictable.
Decision
I fixed the Hooks problems first and only then switched the compiler on. The compiler cannot safely optimize components that break the rules, so turning it on first would have hidden the problem instead of fixing it.
What I did
- Recorded performance traces and watched re-renders to see where the time went.
- Found the Hooks violations that made behavior unpredictable and blocked automatic optimization.
- Fixed them, then introduced the React Compiler to the project.
- Recorded the same traces again to compare.
Result
Far fewer re-renders, and the slow modules feel noticeably smoother. The compiler memoizes automatically, so the team no longer hand-writes memoization everywhere.
In numbers
Scripting
Rendering
- Without the compiler
- With the compiler
Scripting dropped about 40%. Rendering stayed about the same.
- LCP0.13 s0good up to 2.5 s
- INP80 ms0good up to 200 ms
- CLS00good up to 0.1
Local Chrome DevTools on my machine, with no throttling. The green zone is Chrome's good range.
Measured
- In two recordings of about 45 seconds, scripting time was 10.4 s with the compiler and 17.3 s without, roughly 40% less. Rendering time stayed about the same, 7.4 s against 7.2 s.
The two recordings were on different screens, so I read the gap as a strong sign, not an exact figure.
Used
- React Compiler
- React DevTools
- Chrome DevTools