main
js 52 lines 1.52 KB
Raw
1 /**
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 * @flow
8 */
9
10 import type {EventPriority} from 'react-reconciler/src/ReactEventPriorities';
11 import type {HostDispatcher} from './shared/ReactDOMTypes';
12
13 import noop from 'shared/noop';
14
15 // This should line up with NoEventPriority from react-reconciler/src/ReactEventPriorities
16 // but we can't depend on the react-reconciler from this isomorphic code.
17 export const NoEventPriority: EventPriority = 0 as any;
18
19 type ReactDOMInternals = {
20 d /* ReactDOMCurrentDispatcher */: HostDispatcher,
21 p /* currentUpdatePriority */: EventPriority,
22 findDOMNode:
23 | null
24 | ((componentOrElement: component(...props: any)) => null | Element | Text),
25 };
26
27 function requestFormReset(element: HTMLFormElement) {
28 throw new Error(
29 'Invalid form element. requestFormReset must be passed a form that was ' +
30 'rendered by React.',
31 );
32 }
33
34 const DefaultDispatcher: HostDispatcher = {
35 f /* flushSyncWork */: noop,
36 r /* requestFormReset */: requestFormReset,
37 D /* prefetchDNS */: noop,
38 C /* preconnect */: noop,
39 L /* preload */: noop,
40 m /* preloadModule */: noop,
41 X /* preinitScript */: noop,
42 S /* preinitStyle */: noop,
43 M /* preinitModuleScript */: noop,
44 };
45
46 const Internals: ReactDOMInternals = {
47 d /* ReactDOMCurrentDispatcher */: DefaultDispatcher,
48 p /* currentUpdatePriority */: NoEventPriority,
49 findDOMNode: null,
50 };
51
52 export default Internals;