Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete enableDiscreteEventFlushingChange #21110

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 4 additions & 26 deletions packages/react-dom/src/events/ReactDOMUpdateBatching.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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();
}
}

Expand Down
2 changes: 0 additions & 2 deletions packages/shared/ReactFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.native-fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.native-oss.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.test-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.testing.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.testing.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions packages/shared/forks/ReactFeatureFlags.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down