main
js 42 lines 1.16 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 import type {AnyNativeEvent} from '../events/PluginModuleType';
10
11 // This exists to avoid circular dependency between ReactDOMEventReplaying
12 // and DOMPluginEventSystem.
13
14 let currentReplayingEvent = null;
15
16 export function setReplayingEvent(event: AnyNativeEvent): void {
17 if (__DEV__) {
18 if (currentReplayingEvent !== null) {
19 console.error(
20 'Expected currently replaying event to be null. This error ' +
21 'is likely caused by a bug in React. Please file an issue.',
22 );
23 }
24 }
25 currentReplayingEvent = event;
26 }
27
28 export function resetReplayingEvent(): void {
29 if (__DEV__) {
30 if (currentReplayingEvent === null) {
31 console.error(
32 'Expected currently replaying event to not be null. This error ' +
33 'is likely caused by a bug in React. Please file an issue.',
34 );
35 }
36 }
37 currentReplayingEvent = null;
38 }
39
40 export function isReplayingEvent(event: AnyNativeEvent): boolean {
41 return event === currentReplayingEvent;
42 }