Skip to content

Commit

Permalink
Remove flag that reverts #15650 (#16372)
Browse files Browse the repository at this point in the history
The change in #15650 has fully rolled out, so we can remove the flag
that reverts it.
  • Loading branch information
acdlite committed Aug 12, 2019
1 parent 2716d91 commit 3eeb645
Show file tree
Hide file tree
Showing 12 changed files with 3 additions and 88 deletions.
10 changes: 0 additions & 10 deletions packages/react-reconciler/src/ReactFiberClassComponent.js
Expand Up @@ -55,7 +55,6 @@ import {
scheduleWork,
flushPassiveEffects,
} from './ReactFiberWorkLoop';
import {revertPassiveEffectsChange} from 'shared/ReactFeatureFlags';
import {requestCurrentSuspenseConfig} from './ReactFiberSuspenseConfig';

const fakeInternalInstance = {};
Expand Down Expand Up @@ -202,9 +201,6 @@ const classComponentUpdater = {
update.callback = callback;
}

if (revertPassiveEffectsChange) {
flushPassiveEffects();
}
enqueueUpdate(fiber, update);
scheduleWork(fiber, expirationTime);
},
Expand All @@ -229,9 +225,6 @@ const classComponentUpdater = {
update.callback = callback;
}

if (revertPassiveEffectsChange) {
flushPassiveEffects();
}
enqueueUpdate(fiber, update);
scheduleWork(fiber, expirationTime);
},
Expand All @@ -255,9 +248,6 @@ const classComponentUpdater = {
update.callback = callback;
}

if (revertPassiveEffectsChange) {
flushPassiveEffects();
}
enqueueUpdate(fiber, update);
scheduleWork(fiber, expirationTime);
},
Expand Down
5 changes: 0 additions & 5 deletions packages/react-reconciler/src/ReactFiberHooks.js
Expand Up @@ -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';

Expand Down Expand Up @@ -1166,10 +1165,6 @@ function dispatchAction<S, A>(
lastRenderPhaseUpdate.next = update;
}
} else {
if (revertPassiveEffectsChange) {
flushPassiveEffects();
}

const currentTime = requestCurrentTime();
const suspenseConfig = requestCurrentSuspenseConfig();
const expirationTime = computeExpirationForFiber(
Expand Down
14 changes: 0 additions & 14 deletions packages/react-reconciler/src/ReactFiberReconciler.js
Expand Up @@ -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,
Expand Down Expand Up @@ -167,9 +166,6 @@ function scheduleRootUpdate(
update.callback = callback;
}

if (revertPassiveEffectsChange) {
flushPassiveEffects();
}
enqueueUpdate(current, update);
scheduleWork(current, expirationTime);

Expand Down Expand Up @@ -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;
Expand All @@ -455,9 +447,6 @@ if (__DEV__) {

// Support DevTools props for function components, forwardRef, memo, host components, etc.
overrideProps = (fiber: Fiber, path: Array<string | number>, value: any) => {
if (revertPassiveEffectsChange) {
flushPassiveEffects();
}
fiber.pendingProps = copyWithSet(fiber.memoizedProps, path, value);
if (fiber.alternate) {
fiber.alternate.pendingProps = fiber.pendingProps;
Expand All @@ -466,9 +455,6 @@ if (__DEV__) {
};

scheduleUpdate = (fiber: Fiber) => {
if (revertPassiveEffectsChange) {
flushPassiveEffects();
}
scheduleWork(fiber, Sync);
};

Expand Down
9 changes: 3 additions & 6 deletions packages/react-reconciler/src/ReactFiberWorkLoop.js
Expand Up @@ -24,7 +24,6 @@ import {
replayFailedUnitOfWorkWithInvokeGuardedCallback,
enableProfilerTimer,
enableSchedulerTracing,
revertPassiveEffectsChange,
warnAboutUnmockedScheduler,
flushSuspenseFallbacksInTests,
disableSchedulerTimeoutBasedOnReactExpirationTime,
Expand Down Expand Up @@ -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) {
Expand Down
Expand Up @@ -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 <Text text={'Count: ' + count} />;
}

act(() => {
ReactNoop.render(<Counter count={0} />, () =>
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')]);
});
});
});
});
2 changes: 0 additions & 2 deletions packages/shared/ReactFeatureFlags.js
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.native-fb.js
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.native-oss.js
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.persistent.js
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.test-renderer.js
Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
Expand Up @@ -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__;
Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.www.js
Expand Up @@ -19,7 +19,6 @@ export const {
disableInputAttributeSyncing,
warnAboutShorthandPropertyCollision,
warnAboutDeprecatedSetNativeProps,
revertPassiveEffectsChange,
enableUserBlockingEvents,
disableLegacyContext,
disableSchedulerTimeoutBasedOnReactExpirationTime,
Expand Down

0 comments on commit 3eeb645

Please sign in to comment.