UNPKG

2.13 kBTypeScriptView Raw
1/**
2 * These are types for things that are present in the `experimental` builds of React but not yet
3 * on a stable build.
4 *
5 * Once they are promoted to stable they can just be moved to the main index file.
6 *
7 * To load the types declared here in an actual project, there are three ways. The easiest one,
8 * if your `tsconfig.json` already has a `"types"` array in the `"compilerOptions"` section,
9 * is to add `"react/experimental"` to the `"types"` array.
10 *
11 * Alternatively, a specific import syntax can to be used from a typescript file.
12 * This module does not exist in reality, which is why the {} is important:
13 *
14 * ```ts
15 * import {} from 'react/experimental'
16 * ```
17 *
18 * It is also possible to include it through a triple-slash reference:
19 *
20 * ```ts
21 * /// <reference types="react/experimental" />
22 * ```
23 *
24 * Either the import or the reference only needs to appear once, anywhere in the project.
25 */
26
27// See https://github.com/facebook/react/blob/master/packages/react/src/React.js to see how the exports are declared,
28// and https://github.com/facebook/react/blob/master/packages/shared/ReactFeatureFlags.js to verify which APIs are
29// flagged experimental or not. Experimental APIs will be tagged with `__EXPERIMENTAL__`.
30//
31// For the inputs of types exported as simply a fiber tag, the `beginWork` function of ReactFiberBeginWork.js
32// is a good place to start looking for details; it generally calls prop validation functions or delegates
33// all tasks done as part of the render phase (the concurrent part of the React update cycle).
34//
35// Suspense-related handling can be found in ReactFiberThrow.js.
36
37import React = require('./next');
38
39export {};
40
41declare module '.' {
42 /**
43 * @param subscribe
44 * @param getSnapshot
45 *
46 * @see https://github.com/reactwg/react-18/discussions/86
47 */
48 // keep in sync with `useSyncExternalStore` from `use-sync-external-store`
49 export function unstable_useSyncExternalStore<Snapshot>(
50 subscribe: (onStoreChange: () => void) => () => void,
51 getSnapshot: () => Snapshot,
52 getServerSnapshot?: () => Snapshot,
53 ): Snapshot;
54}