React Compiler Has Been Released to Public!


Martin Omacht
Specifying hook dependencies has been one of the biggest pain points of React. They have stated in the official docs, that this will be handled automatically in the future. We have waited 5 long years for this, but it is finally coming. At the official React conference React Conf 2024.

What are the biggest changes?

Specifying hook dependencies has been one of the biggest pain points of React. They have stated in the official docs, that this will be handled automatically in the future. We have waited 5 long years for this, but it is finally coming. At the official React conference React Conf 2024, React team unveiled that their research project React Compiler (previously called React Forget) has been open-sourced. It is still experimental, however, it has been used successfully in production on instagram.com. This is a big milestone and should mean that the official stable release is close.

React Compiler will only tackle memoization hooks (useCallback, useMemo and React.memo) and not the useEffect hook. So the days of dependency arrays are not going to be over yet, but we can hope that they will cover useEffect in the future. Although it may be more tricky to implement into existing codebases as this hook is often used incorrectly (mainly not having an exhaustive list of dependencies) and in these cases the compiler probably wouldn’t work.

How is it going to work?

It’s not that you may omit the dependency array in useMemo or useCallback hooks, but you can omit these hooks all together. During the build step the React Compiler will automatically detect dependencies and memoize functions, values and even components (instead of React.memo). The performance gains will depend on how well the app was hand-optimized before and if your codebase breaks the Rules of Hooks a lot (it will skip memoizing code that breaks rules), but from available benchmarks it can optimize the memoization at least as well as humans can and sometimes even better.

React Compiler can dramatically increase the developer experience of React and could stabilize the position of React in the JS ecosystem even more, because from my experience, DX is one of the main things causing people to switch to other frameworks.

Did you get inspired?

Martin Omacht

Frontend Developer

Martin Omacht is an experienced frontend developer at ARTIN, specializing in React and TypeScript. With extensive experience leading innovative projects and a passion for exploring the latest in JavaScript technologies, Martin brings a wealth of knowledge to his writings. When not coding, he enjoys disc golf, skiing, and crafting intricate miniature models.
Martin Omacht

We're here as well