dillon1000/react

Commit

[rcr] Re-export useMemoCache in top level React namespace (#31139)

In order to support using the compiler on versions of React prior to 19,
we need the ability to statically import `c` (aka useMemoCache) or
fallback to a polyfill supplied by `react-compiler-runtime` (note: this
is a separate npm package, not to be confused with
`react/compiler-runtime`, which is currently a part of react).

To do this we first need to re-export `useMemoCache` under the top level
React namespace again, which is additive and thus non-breaking. Doing so
allows `react-compiler-runtime` to statically either re-export
`React.__COMPILER_RUNTIME.c` or supply a polyfill, without the need for
a dynamic import which is finicky to support due to returning a promise.

In later PRs I will remove `react/compiler-runtime` and update the
compiler to emit imports to `react-compiler-runtime` instead.
Browse files
Changed paths7 files
First-parent comparison
M packages/react/index.development.js ModifiedM packages/react/index.experimental.development.js ModifiedM packages/react/index.experimental.js ModifiedM packages/react/index.fb.js ModifiedM packages/react/index.js ModifiedM packages/react/src/ReactClient.js ModifiedA packages/react/src/ReactCompilerRuntime.js Added
Patch

Files changed

Rendering syntax-highlighted changes…