mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Delete enableDiscreteEventFlushingChange (#21110)
This flag was meant to avoid flushing discrete updates unnecessarily, if multiple discrete events were dispatched in response to the same platform event. But since we now flush all discrete events at the end of the task, in a microtask, it no longer has any effect.
This commit is contained in:
+4
-26
@@ -9,7 +9,6 @@ import {
|
||||
needsStateRestore,
|
||||
restoreStateIfNeeded,
|
||||
} from './ReactDOMControlledComponent';
|
||||
import {enableDiscreteEventFlushingChange} from 'shared/ReactFeatureFlags';
|
||||
|
||||
// Used as a way to call batchedUpdates when we don't have a reference to
|
||||
// the renderer. Such as when we're dispatching events or if third party
|
||||
@@ -75,6 +74,7 @@ export function batchedEventUpdates(fn, a, b) {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Replace with flushSync
|
||||
export function discreteUpdates(fn, a, b, c, d) {
|
||||
const prevIsInsideEventHandler = isInsideEventHandler;
|
||||
isInsideEventHandler = true;
|
||||
@@ -88,32 +88,10 @@ export function discreteUpdates(fn, a, b, c, d) {
|
||||
}
|
||||
}
|
||||
|
||||
let lastFlushedEventTimeStamp = 0;
|
||||
// TODO: Replace with flushSync
|
||||
export function flushDiscreteUpdatesIfNeeded(timeStamp: number) {
|
||||
if (enableDiscreteEventFlushingChange) {
|
||||
// event.timeStamp isn't overly reliable due to inconsistencies in
|
||||
// how different browsers have historically provided the time stamp.
|
||||
// Some browsers provide high-resolution time stamps for all events,
|
||||
// some provide low-resolution time stamps for all events. FF < 52
|
||||
// even mixes both time stamps together. Some browsers even report
|
||||
// negative time stamps or time stamps that are 0 (iOS9) in some cases.
|
||||
// Given we are only comparing two time stamps with equality (!==),
|
||||
// we are safe from the resolution differences. If the time stamp is 0
|
||||
// we bail-out of preventing the flush, which can affect semantics,
|
||||
// such as if an earlier flush removes or adds event listeners that
|
||||
// are fired in the subsequent flush. However, this is the same
|
||||
// behaviour as we had before this change, so the risks are low.
|
||||
if (
|
||||
!isInsideEventHandler &&
|
||||
(timeStamp === 0 || lastFlushedEventTimeStamp !== timeStamp)
|
||||
) {
|
||||
lastFlushedEventTimeStamp = timeStamp;
|
||||
flushDiscreteUpdatesImpl();
|
||||
}
|
||||
} else {
|
||||
if (!isInsideEventHandler) {
|
||||
flushDiscreteUpdatesImpl();
|
||||
}
|
||||
if (!isInsideEventHandler) {
|
||||
flushDiscreteUpdatesImpl();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -155,8 +155,6 @@ export const enableLegacyFBSupport = false;
|
||||
// new behavior.
|
||||
export const deferRenderPhaseUpdateToNextBatch = true;
|
||||
|
||||
export const enableDiscreteEventFlushingChange = false;
|
||||
|
||||
export const enableUseRefAccessWarning = false;
|
||||
|
||||
export const enableRecursiveCommitTraversal = false;
|
||||
|
||||
@@ -50,7 +50,6 @@ export const deletedTreeCleanUpLevel = 1;
|
||||
|
||||
export const enableNewReconciler = false;
|
||||
export const deferRenderPhaseUpdateToNextBatch = true;
|
||||
export const enableDiscreteEventFlushingChange = false;
|
||||
|
||||
export const enableStrictEffects = false;
|
||||
export const createRootStrictEffectsByDefault = false;
|
||||
|
||||
@@ -49,7 +49,6 @@ export const deletedTreeCleanUpLevel = 1;
|
||||
|
||||
export const enableNewReconciler = false;
|
||||
export const deferRenderPhaseUpdateToNextBatch = true;
|
||||
export const enableDiscreteEventFlushingChange = false;
|
||||
|
||||
export const enableStrictEffects = false;
|
||||
export const createRootStrictEffectsByDefault = false;
|
||||
|
||||
@@ -49,7 +49,6 @@ export const deletedTreeCleanUpLevel = 1;
|
||||
|
||||
export const enableNewReconciler = false;
|
||||
export const deferRenderPhaseUpdateToNextBatch = true;
|
||||
export const enableDiscreteEventFlushingChange = false;
|
||||
|
||||
export const enableStrictEffects = false;
|
||||
export const createRootStrictEffectsByDefault = false;
|
||||
|
||||
@@ -49,7 +49,6 @@ export const deletedTreeCleanUpLevel = 1;
|
||||
|
||||
export const enableNewReconciler = false;
|
||||
export const deferRenderPhaseUpdateToNextBatch = true;
|
||||
export const enableDiscreteEventFlushingChange = false;
|
||||
|
||||
export const enableStrictEffects = false;
|
||||
export const createRootStrictEffectsByDefault = false;
|
||||
|
||||
@@ -49,7 +49,6 @@ export const deletedTreeCleanUpLevel = 1;
|
||||
|
||||
export const enableNewReconciler = false;
|
||||
export const deferRenderPhaseUpdateToNextBatch = true;
|
||||
export const enableDiscreteEventFlushingChange = false;
|
||||
|
||||
export const enableStrictEffects = true;
|
||||
export const createRootStrictEffectsByDefault = false;
|
||||
|
||||
@@ -49,7 +49,6 @@ export const deletedTreeCleanUpLevel = 1;
|
||||
|
||||
export const enableNewReconciler = false;
|
||||
export const deferRenderPhaseUpdateToNextBatch = true;
|
||||
export const enableDiscreteEventFlushingChange = false;
|
||||
|
||||
export const enableStrictEffects = false;
|
||||
export const createRootStrictEffectsByDefault = false;
|
||||
|
||||
@@ -49,7 +49,6 @@ export const deletedTreeCleanUpLevel = 1;
|
||||
|
||||
export const enableNewReconciler = false;
|
||||
export const deferRenderPhaseUpdateToNextBatch = true;
|
||||
export const enableDiscreteEventFlushingChange = true;
|
||||
|
||||
export const enableStrictEffects = false;
|
||||
export const createRootStrictEffectsByDefault = false;
|
||||
|
||||
@@ -83,8 +83,6 @@ export const disableTextareaChildren = __EXPERIMENTAL__;
|
||||
|
||||
export const warnUnstableRenderSubtreeIntoContainer = false;
|
||||
|
||||
export const enableDiscreteEventFlushingChange = true;
|
||||
|
||||
// Enable forked reconciler. Piggy-backing on the "variant" global so that we
|
||||
// don't have to add another test dimension. The build system will compile this
|
||||
// to the correct value.
|
||||
|
||||
Reference in New Issue
Block a user