From 3eeb645515fad1c5f99339744d0f8804b9c6ced1 Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Mon, 12 Aug 2019 14:31:12 -0700 Subject: [PATCH] Remove flag that reverts #15650 (#16372) The change in #15650 has fully rolled out, so we can remove the flag that reverts it. --- .../src/ReactFiberClassComponent.js | 10 ----- .../react-reconciler/src/ReactFiberHooks.js | 5 --- .../src/ReactFiberReconciler.js | 14 ------ .../src/ReactFiberWorkLoop.js | 9 ++-- ...eactHooksWithNoopRenderer-test.internal.js | 43 ------------------- packages/shared/ReactFeatureFlags.js | 2 - .../forks/ReactFeatureFlags.native-fb.js | 1 - .../forks/ReactFeatureFlags.native-oss.js | 1 - .../forks/ReactFeatureFlags.persistent.js | 1 - .../forks/ReactFeatureFlags.test-renderer.js | 1 - .../ReactFeatureFlags.test-renderer.www.js | 3 -- .../shared/forks/ReactFeatureFlags.www.js | 1 - 12 files changed, 3 insertions(+), 88 deletions(-) diff --git a/packages/react-reconciler/src/ReactFiberClassComponent.js b/packages/react-reconciler/src/ReactFiberClassComponent.js index a8dc4079ae265..18285d83a3dd1 100644 --- a/packages/react-reconciler/src/ReactFiberClassComponent.js +++ b/packages/react-reconciler/src/ReactFiberClassComponent.js @@ -55,7 +55,6 @@ import { scheduleWork, flushPassiveEffects, } from './ReactFiberWorkLoop'; -import {revertPassiveEffectsChange} from 'shared/ReactFeatureFlags'; import {requestCurrentSuspenseConfig} from './ReactFiberSuspenseConfig'; const fakeInternalInstance = {}; @@ -202,9 +201,6 @@ const classComponentUpdater = { update.callback = callback; } - if (revertPassiveEffectsChange) { - flushPassiveEffects(); - } enqueueUpdate(fiber, update); scheduleWork(fiber, expirationTime); }, @@ -229,9 +225,6 @@ const classComponentUpdater = { update.callback = callback; } - if (revertPassiveEffectsChange) { - flushPassiveEffects(); - } enqueueUpdate(fiber, update); scheduleWork(fiber, expirationTime); }, @@ -255,9 +248,6 @@ const classComponentUpdater = { update.callback = callback; } - if (revertPassiveEffectsChange) { - flushPassiveEffects(); - } enqueueUpdate(fiber, update); scheduleWork(fiber, expirationTime); }, diff --git a/packages/react-reconciler/src/ReactFiberHooks.js b/packages/react-reconciler/src/ReactFiberHooks.js index 5ffc5f00f28d4..e85b723ebd751 100644 --- a/packages/react-reconciler/src/ReactFiberHooks.js +++ b/packages/react-reconciler/src/ReactFiberHooks.js @@ -51,7 +51,6 @@ import warning from 'shared/warning'; import getComponentName from 'shared/getComponentName'; import is from 'shared/objectIs'; import {markWorkInProgressReceivedUpdate} from './ReactFiberBeginWork'; -import {revertPassiveEffectsChange} from 'shared/ReactFeatureFlags'; import {requestCurrentSuspenseConfig} from './ReactFiberSuspenseConfig'; import {getCurrentPriorityLevel} from './SchedulerWithReactIntegration'; @@ -1166,10 +1165,6 @@ function dispatchAction( lastRenderPhaseUpdate.next = update; } } else { - if (revertPassiveEffectsChange) { - flushPassiveEffects(); - } - const currentTime = requestCurrentTime(); const suspenseConfig = requestCurrentSuspenseConfig(); const expirationTime = computeExpirationForFiber( diff --git a/packages/react-reconciler/src/ReactFiberReconciler.js b/packages/react-reconciler/src/ReactFiberReconciler.js index 6663699d8b700..dc62033d9389d 100644 --- a/packages/react-reconciler/src/ReactFiberReconciler.js +++ b/packages/react-reconciler/src/ReactFiberReconciler.js @@ -70,7 +70,6 @@ import { } from './ReactCurrentFiber'; import {StrictMode} from './ReactTypeOfMode'; import {Sync} from './ReactFiberExpirationTime'; -import {revertPassiveEffectsChange} from 'shared/ReactFeatureFlags'; import {requestCurrentSuspenseConfig} from './ReactFiberSuspenseConfig'; import { scheduleRefresh, @@ -167,9 +166,6 @@ function scheduleRootUpdate( update.callback = callback; } - if (revertPassiveEffectsChange) { - flushPassiveEffects(); - } enqueueUpdate(current, update); scheduleWork(current, expirationTime); @@ -434,10 +430,6 @@ if (__DEV__) { id--; } if (currentHook !== null) { - if (revertPassiveEffectsChange) { - flushPassiveEffects(); - } - const newState = copyWithSet(currentHook.memoizedState, path, value); currentHook.memoizedState = newState; currentHook.baseState = newState; @@ -455,9 +447,6 @@ if (__DEV__) { // Support DevTools props for function components, forwardRef, memo, host components, etc. overrideProps = (fiber: Fiber, path: Array, value: any) => { - if (revertPassiveEffectsChange) { - flushPassiveEffects(); - } fiber.pendingProps = copyWithSet(fiber.memoizedProps, path, value); if (fiber.alternate) { fiber.alternate.pendingProps = fiber.pendingProps; @@ -466,9 +455,6 @@ if (__DEV__) { }; scheduleUpdate = (fiber: Fiber) => { - if (revertPassiveEffectsChange) { - flushPassiveEffects(); - } scheduleWork(fiber, Sync); }; diff --git a/packages/react-reconciler/src/ReactFiberWorkLoop.js b/packages/react-reconciler/src/ReactFiberWorkLoop.js index 3e182a1f7d0db..e67df799a20e3 100644 --- a/packages/react-reconciler/src/ReactFiberWorkLoop.js +++ b/packages/react-reconciler/src/ReactFiberWorkLoop.js @@ -24,7 +24,6 @@ import { replayFailedUnitOfWorkWithInvokeGuardedCallback, enableProfilerTimer, enableSchedulerTracing, - revertPassiveEffectsChange, warnAboutUnmockedScheduler, flushSuspenseFallbacksInTests, disableSchedulerTimeoutBasedOnReactExpirationTime, @@ -621,11 +620,9 @@ export function flushDiscreteUpdates() { return; } flushPendingDiscreteUpdates(); - if (!revertPassiveEffectsChange) { - // If the discrete updates scheduled passive effects, flush them now so that - // they fire before the next serial event. - flushPassiveEffects(); - } + // If the discrete updates scheduled passive effects, flush them now so that + // they fire before the next serial event. + flushPassiveEffects(); } function resolveLocksOnRoot(root: FiberRoot, expirationTime: ExpirationTime) { diff --git a/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.internal.js b/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.internal.js index 6309ffbf67325..2d242109d9b08 100644 --- a/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.internal.js +++ b/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.internal.js @@ -2170,47 +2170,4 @@ describe('ReactHooksWithNoopRenderer', () => { expect(Scheduler).toHaveYielded(['Step: 5, Shadow: 5']); expect(ReactNoop).toMatchRenderedOutput('5'); }); - - describe('revertPassiveEffectsChange', () => { - it('flushes serial effects before enqueueing work', () => { - jest.resetModules(); - - ReactFeatureFlags = require('shared/ReactFeatureFlags'); - ReactFeatureFlags.debugRenderPhaseSideEffectsForStrictMode = false; - ReactFeatureFlags.enableSchedulerTracing = true; - ReactFeatureFlags.revertPassiveEffectsChange = true; - React = require('react'); - ReactNoop = require('react-noop-renderer'); - Scheduler = require('scheduler'); - SchedulerTracing = require('scheduler/tracing'); - useState = React.useState; - useEffect = React.useEffect; - act = ReactNoop.act; - - let _updateCount; - function Counter(props) { - const [count, updateCount] = useState(0); - _updateCount = updateCount; - useEffect(() => { - Scheduler.unstable_yieldValue(`Will set count to 1`); - updateCount(1); - }, []); - return ; - } - - act(() => { - ReactNoop.render(, () => - Scheduler.unstable_yieldValue('Sync effect'), - ); - expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']); - expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]); - // Enqueuing this update forces the passive effect to be flushed -- - // updateCount(1) happens first, so 2 wins. - act(() => _updateCount(2)); - expect(Scheduler).toHaveYielded(['Will set count to 1']); - expect(Scheduler).toFlushAndYield(['Count: 2']); - expect(ReactNoop.getChildren()).toEqual([span('Count: 2')]); - }); - }); - }); }); diff --git a/packages/shared/ReactFeatureFlags.js b/packages/shared/ReactFeatureFlags.js index f3ebeaa96c48e..34d482cf2b46b 100644 --- a/packages/shared/ReactFeatureFlags.js +++ b/packages/shared/ReactFeatureFlags.js @@ -71,8 +71,6 @@ export const enableJSXTransformAPI = false; // We will enforce mocking scheduler with scheduler/unstable_mock at some point. (v17?) // Till then, we warn about the missing mock, but still fallback to a sync mode compatible version export const warnAboutUnmockedScheduler = false; -// Temporary flag to revert the fix in #15650 -export const revertPassiveEffectsChange = false; // For tests, we flush suspense fallbacks in an act scope; // *except* in some of our own tests, where we test incremental loading states. diff --git a/packages/shared/forks/ReactFeatureFlags.native-fb.js b/packages/shared/forks/ReactFeatureFlags.native-fb.js index 44ddfca0eb5d2..9dbed7ab7f987 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-fb.js +++ b/packages/shared/forks/ReactFeatureFlags.native-fb.js @@ -35,7 +35,6 @@ export const enableFlareAPI = false; export const enableFundamentalAPI = false; export const enableJSXTransformAPI = false; export const warnAboutUnmockedScheduler = true; -export const revertPassiveEffectsChange = false; export const flushSuspenseFallbacksInTests = true; export const enableUserBlockingEvents = false; export const enableSuspenseCallback = false; diff --git a/packages/shared/forks/ReactFeatureFlags.native-oss.js b/packages/shared/forks/ReactFeatureFlags.native-oss.js index 7db7b5728a246..4201b41bd266d 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-oss.js +++ b/packages/shared/forks/ReactFeatureFlags.native-oss.js @@ -30,7 +30,6 @@ export const enableFlareAPI = false; export const enableFundamentalAPI = false; export const enableJSXTransformAPI = false; export const warnAboutUnmockedScheduler = false; -export const revertPassiveEffectsChange = false; export const flushSuspenseFallbacksInTests = true; export const enableUserBlockingEvents = false; export const enableSuspenseCallback = false; diff --git a/packages/shared/forks/ReactFeatureFlags.persistent.js b/packages/shared/forks/ReactFeatureFlags.persistent.js index 8b270ca3345b1..23d936b7eb50c 100644 --- a/packages/shared/forks/ReactFeatureFlags.persistent.js +++ b/packages/shared/forks/ReactFeatureFlags.persistent.js @@ -30,7 +30,6 @@ export const enableFlareAPI = false; export const enableFundamentalAPI = false; export const enableJSXTransformAPI = false; export const warnAboutUnmockedScheduler = true; -export const revertPassiveEffectsChange = false; export const flushSuspenseFallbacksInTests = true; export const enableUserBlockingEvents = false; export const enableSuspenseCallback = false; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.js index 3c6a3ba303010..c308b949db368 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.js @@ -30,7 +30,6 @@ export const enableFlareAPI = false; export const enableFundamentalAPI = false; export const enableJSXTransformAPI = false; export const warnAboutUnmockedScheduler = false; -export const revertPassiveEffectsChange = false; export const flushSuspenseFallbacksInTests = true; export const enableUserBlockingEvents = false; export const enableSuspenseCallback = false; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js index 22ea2c0148982..b452e018ef45b 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js @@ -12,9 +12,6 @@ import invariant from 'shared/invariant'; import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags'; import typeof * as PersistentFeatureFlagsType from './ReactFeatureFlags.persistent'; -// Re-export dynamic flags from the www version. -export const {revertPassiveEffectsChange} = require('ReactFeatureFlags'); - export const debugRenderPhaseSideEffects = false; export const debugRenderPhaseSideEffectsForStrictMode = false; export const enableUserTimingAPI = __DEV__; diff --git a/packages/shared/forks/ReactFeatureFlags.www.js b/packages/shared/forks/ReactFeatureFlags.www.js index 8a464fde64277..8965f4d42155f 100644 --- a/packages/shared/forks/ReactFeatureFlags.www.js +++ b/packages/shared/forks/ReactFeatureFlags.www.js @@ -19,7 +19,6 @@ export const { disableInputAttributeSyncing, warnAboutShorthandPropertyCollision, warnAboutDeprecatedSetNativeProps, - revertPassiveEffectsChange, enableUserBlockingEvents, disableLegacyContext, disableSchedulerTimeoutBasedOnReactExpirationTime,