r/reactjs • u/HamzaSiddiqueDev • 2d ago
Discussion React Compiler Working Structure
React Compiler was introduced in React 19 so I want to know that how it works internally. Seeking deep research knowledge on React Compiler in simple English.
0
Upvotes
View all comments
4
u/anthony-ball 2d ago
Worth knowing first: it isn't really part of React 19 itself, it's a separate build-time Babel plugin (babel-plugin-react-compiler) and it also works on 17/18 with the runtime package. At build time it reads each component and hook, works out which values depend on which props and state, and caches those pieces in a per-component memo cache, so it's basically auto useMemo/useCallback/React.memo but more granular than you'd ever write by hand. If a component breaks the Rules of React (mutating props, reading refs during render, etc.) it just skips that component instead of guessing. The quickest way to actually get it is playground.react.dev: paste a small component and read the compiled output side by side.