forked from facebook/react
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathReactSharedInternalsClient.js
60 lines (48 loc) · 1.9 KB
/
ReactSharedInternalsClient.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* 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
*/
import type {Dispatcher} from 'react-reconciler/src/ReactInternalTypes';
import type {AsyncDispatcher} from 'react-reconciler/src/ReactInternalTypes';
import type {BatchConfigTransition} from 'react-reconciler/src/ReactFiberTracingMarkerComponent';
export type SharedStateClient = {
H: null | Dispatcher, // ReactCurrentDispatcher for Hooks
A: null | AsyncDispatcher, // ReactCurrentCache for Cache
T: null | BatchConfigTransition, // ReactCurrentBatchConfig for Transitions
S: null | ((BatchConfigTransition, mixed) => void), // onStartTransitionFinish
// DEV-only
// ReactCurrentActQueue
actQueue: null | Array<RendererTask>,
// Used to reproduce behavior of `batchedUpdates` in legacy mode.
isBatchingLegacy: boolean,
didScheduleLegacyUpdate: boolean,
// Tracks whether something called `use` during the current batch of work.
// Determines whether we should yield to microtasks to unwrap already resolved
// promises without suspending.
didUsePromise: boolean,
// Track first uncaught error within this act
thrownErrors: Array<mixed>,
// ReactDebugCurrentFrame
getCurrentStack: null | (() => string),
};
export type RendererTask = boolean => RendererTask | null;
const ReactSharedInternals: SharedStateClient = ({
H: null,
A: null,
T: null,
S: null,
}: any);
if (__DEV__) {
ReactSharedInternals.actQueue = null;
ReactSharedInternals.isBatchingLegacy = false;
ReactSharedInternals.didScheduleLegacyUpdate = false;
ReactSharedInternals.didUsePromise = false;
ReactSharedInternals.thrownErrors = [];
// Stack implementation injected by the current renderer.
ReactSharedInternals.getCurrentStack = (null: null | (() => string));
}
export default ReactSharedInternals;