React Compiler chatter and warnings
Social posts flagged upcoming deep dives into React Compiler at future conferences and warned that mutating ref.current during render can break compatibility with the compiler. The notes are aimed at library authors who are optimizing internals and need to avoid patterns that the compiler cannot handle. (x.com/i/status/2041427781498667328) (x.com/wooing0306/status/2041752001672081525)
React Compiler is pushing library authors toward a stricter rule: don’t read or write `ref.current` while a component is rendering. (react.dev 1) (react.dev 2) The compiler is a build-time optimizer for React that automatically skips work when values have not changed, replacing much of the manual memoization developers used to write by hand. React’s docs say it works best with React 19, supports React 17 and 18, and ships as a Babel plugin. (react.dev 1) (react.dev 2) Refs are React’s “escape hatch” for values that do not drive what appears on screen, such as a DOM node, a timeout ID, or an imperative handle. React’s `useRef` docs say changing `ref.current` does not trigger a re-render, because React does not track that field the way it tracks state. (react.dev 1) (react.dev 2) That is why the rule is tightening around render itself, the phase where React calculates what the user interface should look like. React’s lint rule for refs says reading or writing `ref.current` during render “breaks React’s expectations” and can leave values stale, inconsistent, or uninitialized. (react.dev) React’s own `useRef` reference leaves one narrow exception for initialization, but the compiler and its linting rules are less forgiving about common patterns that library authors have used for years. A GitHub issue filed in 2025 shows the compiler de-optimizing code that checks `if (!ref.current)` or `if (ref.current === undefined)` during render, with the warning “Cannot access refs during render.” (react.dev) (github.com) That distinction lands hardest on library authors, because they are more likely to pack caches, measurements, and instance bookkeeping into refs inside low-level hooks. React now has a dedicated guide for “Compiling Libraries” that tells maintainers how to ship pre-compiled code and keep it compatible across app setups. (react.dev) The compiler is no longer a side project on the edge of the ecosystem. React announced version 1.0 on October 7, 2025, and said compiler-powered lint rules were added to the recommended presets for `eslint-plugin-react-hooks`, alongside adoption guides and integrations with Expo, Vite, and Next.js. (react.dev) Conference programming suggests React plans to keep explaining those constraints in public. The React Conf 2025 agenda listed a React keynote on October 7, 2025 and a React team question-and-answer session later the same day, giving the team a recurring venue to push compiler guidance to framework and library maintainers. (conf.react.dev) The practical takeaway is narrower than a blanket ban on refs: React still documents refs for DOM access and other imperative tasks, but it wants those reads and writes moved out of render and into places like event handlers, effects, or callback refs. As the compiler spreads, code that once merely “worked” is being sorted into patterns React can safely analyze and patterns it will skip. (react.dev) (react.dev)