5
5
* LICENSE file in the root directory of this source tree.
6
6
*/
7
7
8
- import {
9
- needsStateRestore ,
10
- restoreStateIfNeeded ,
11
- } from './ReactControlledComponent' ;
12
-
13
- import { enableDeprecatedFlareAPI } from 'shared/ReactFeatureFlags' ;
14
- import { invokeGuardedCallbackAndCatchFirstError } from 'shared/ReactErrorUtils' ;
15
-
16
8
// Used as a way to call batchedUpdates when we don't have a reference to
17
9
// the renderer. Such as when we're dispatching events or if third party
18
10
// libraries need to call batchedUpdates. Eventually, this API will go away when
@@ -32,21 +24,6 @@ let batchedEventUpdatesImpl = batchedUpdatesImpl;
32
24
let isInsideEventHandler = false ;
33
25
let isBatchingEventUpdates = false ;
34
26
35
- function finishEventHandler ( ) {
36
- // Here we wait until all updates have propagated, which is important
37
- // when using controlled components within layers:
38
- // https://github.com/facebook/react/issues/1698
39
- // Then we restore state of any controlled component.
40
- const controlledComponentsHavePendingUpdates = needsStateRestore ( ) ;
41
- if ( controlledComponentsHavePendingUpdates ) {
42
- // If a controlled event was fired, we may need to restore the state of
43
- // the DOM node back to the controlled value. This is necessary when React
44
- // bails out of the update without touching the DOM.
45
- flushDiscreteUpdatesImpl ( ) ;
46
- restoreStateIfNeeded ( ) ;
47
- }
48
- }
49
-
50
27
export function batchedUpdates ( fn , bookkeeping ) {
51
28
if ( isInsideEventHandler ) {
52
29
// If we are currently inside another batch, we need to wait until it
@@ -58,7 +35,6 @@ export function batchedUpdates(fn, bookkeeping) {
58
35
return batchedUpdatesImpl ( fn , bookkeeping ) ;
59
36
} finally {
60
37
isInsideEventHandler = false ;
61
- finishEventHandler ( ) ;
62
38
}
63
39
}
64
40
@@ -73,19 +49,6 @@ export function batchedEventUpdates(fn, a, b) {
73
49
return batchedEventUpdatesImpl ( fn , a , b ) ;
74
50
} finally {
75
51
isBatchingEventUpdates = false ;
76
- finishEventHandler ( ) ;
77
- }
78
- }
79
-
80
- // This is for the React Flare event system
81
- export function executeUserEventHandler ( fn : any => void , value : any ) : void {
82
- const previouslyInEventHandler = isInsideEventHandler ;
83
- try {
84
- isInsideEventHandler = true ;
85
- const type = typeof value === 'object' && value !== null ? value . type : '' ;
86
- invokeGuardedCallbackAndCatchFirstError ( type , fn , undefined , value ) ;
87
- } finally {
88
- isInsideEventHandler = previouslyInEventHandler ;
89
52
}
90
53
}
91
54
@@ -97,32 +60,12 @@ export function discreteUpdates(fn, a, b, c, d) {
97
60
} finally {
98
61
isInsideEventHandler = prevIsInsideEventHandler ;
99
62
if ( ! isInsideEventHandler ) {
100
- finishEventHandler ( ) ;
101
63
}
102
64
}
103
65
}
104
66
105
- let lastFlushedEventTimeStamp = 0 ;
106
67
export function flushDiscreteUpdatesIfNeeded ( timeStamp : number ) {
107
- // event.timeStamp isn't overly reliable due to inconsistencies in
108
- // how different browsers have historically provided the time stamp.
109
- // Some browsers provide high-resolution time stamps for all events,
110
- // some provide low-resolution time stamps for all events. FF < 52
111
- // even mixes both time stamps together. Some browsers even report
112
- // negative time stamps or time stamps that are 0 (iOS9) in some cases.
113
- // Given we are only comparing two time stamps with equality (!==),
114
- // we are safe from the resolution differences. If the time stamp is 0
115
- // we bail-out of preventing the flush, which can affect semantics,
116
- // such as if an earlier flush removes or adds event listeners that
117
- // are fired in the subsequent flush. However, this is the same
118
- // behaviour as we had before this change, so the risks are low.
119
- if (
120
- ! isInsideEventHandler &&
121
- ( ! enableDeprecatedFlareAPI ||
122
- timeStamp === 0 ||
123
- lastFlushedEventTimeStamp !== timeStamp )
124
- ) {
125
- lastFlushedEventTimeStamp = timeStamp ;
68
+ if ( ! isInsideEventHandler ) {
126
69
flushDiscreteUpdatesImpl ( ) ;
127
70
}
128
71
}
0 commit comments