/** * These are types for things that are present in the `experimental` builds of React but not yet * on a stable build. * * Once they are promoted to stable they can just be moved to the main index file. * * To load the types declared here in an actual project, there are three ways. The easiest one, * if your `tsconfig.json` already has a `"types"` array in the `"compilerOptions"` section, * is to add `"react/experimental"` to the `"types"` array. * * Alternatively, a specific import syntax can to be used from a typescript file. * This module does not exist in reality, which is why the {} is important: * * ```ts * import {} from 'react/experimental' * ``` * * It is also possible to include it through a triple-slash reference: * * ```ts * /// * ``` * * Either the import or the reference only needs to appear once, anywhere in the project. */ // See https://github.com/facebook/react/blob/master/packages/react/src/React.js to see how the exports are declared, // and https://github.com/facebook/react/blob/master/packages/shared/ReactFeatureFlags.js to verify which APIs are // flagged experimental or not. Experimental APIs will be tagged with `__EXPERIMENTAL__`. // // For the inputs of types exported as simply a fiber tag, the `beginWork` function of ReactFiberBeginWork.js // is a good place to start looking for details; it generally calls prop validation functions or delegates // all tasks done as part of the render phase (the concurrent part of the React update cycle). // // Suspense-related handling can be found in ReactFiberThrow.js. import React = require('./next'); export {}; declare module '.' { /** * @param subscribe * @param getSnapshot * * @see https://github.com/reactwg/react-18/discussions/86 */ // keep in sync with `useSyncExternalStore` from `use-sync-external-store` export function unstable_useSyncExternalStore( subscribe: (onStoreChange: () => void) => () => void, getSnapshot: () => Snapshot, getServerSnapshot?: () => Snapshot, ): Snapshot; /** * @param effect Imperative function that can return a cleanup function * @param deps If present, effect will only activate if the values in the list change. * * @see https://github.com/facebook/react/pull/21913 */ export function unstable_useInsertionEffect(effect: EffectCallback, deps?: DependencyList): void; }