r/reactjs • • 7d 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

11 comments sorted by

View all comments

1

u/atta542 7d ago

short version: it's a babel plugin that runs at build time, it's not something running inside react itself. it turns each component into its own intermediate representation, works out which values depend on which props and state, and then rewrites the component so those values get cached. if you paste a component into the react compiler playground you'll see a _c(n) call at the top of the output, that's a cache array, and the compiled code checks whether the inputs changed before recomputing things or recreating jsx. so it's basically writing the useMemo/useCallback/memo you would have written by hand. the playground is honestly the easiest way to get it, look at input and output side by side for a few components