Files
react/packages/react/index.fb.js
lauren b78a7f2f35 [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.
2024-10-07 16:25:04 -04:00

70 lines
1.4 KiB
JavaScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
export {
__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
__COMPILER_RUNTIME,
act,
cache,
Children,
cloneElement,
Component,
createContext,
createElement,
createRef,
experimental_useEffectEvent,
forwardRef,
Fragment,
isValidElement,
lazy,
memo,
Profiler,
PureComponent,
startTransition,
StrictMode,
Suspense,
unstable_Activity,
unstable_DebugTracingMode,
unstable_getCacheForType,
unstable_LegacyHidden,
unstable_Scope,
unstable_SuspenseList,
unstable_TracingMarker,
unstable_useCacheRefresh,
use,
useActionState,
useCallback,
unstable_useContextWithBailout,
useContext,
useDebugValue,
useDeferredValue,
useEffect,
useId,
useImperativeHandle,
useInsertionEffect,
useLayoutEffect,
useMemo,
useOptimistic,
useReducer,
useRef,
useState,
useSyncExternalStore,
useTransition,
version,
} from './src/ReactClient';
export {jsx, jsxs, jsxDEV} from './src/jsx/ReactJSX';
// export for backwards compatibility during upgrade
export {useMemoCache as unstable_useMemoCache} from './src/ReactHooks';
// export to match the name of the OSS function typically exported from
// react/compiler-runtime
export {useMemoCache as c} from './src/ReactHooks';