Skip to content

Commit e91dd70

Browse files
authored
Remove disableYielding feature flag (#15654)
Obviated by Batched Mode.
1 parent 4d949d7 commit e91dd70

10 files changed

+4
-105
lines changed

packages/react-dom/src/__tests__/ReactDOMFiberAsync-test.internal.js

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
'use strict';
1111

1212
const React = require('react');
13-
const Fragment = React.Fragment;
1413
let ReactFeatureFlags = require('shared/ReactFeatureFlags');
1514

1615
let ReactDOM;
@@ -602,84 +601,4 @@ describe('ReactDOMFiberAsync', () => {
602601
expect(root.createBatch).toBe(undefined);
603602
});
604603
});
605-
606-
describe('Disable yielding', () => {
607-
beforeEach(() => {
608-
jest.resetModules();
609-
ReactFeatureFlags = require('shared/ReactFeatureFlags');
610-
ReactFeatureFlags.disableYielding = true;
611-
ReactFeatureFlags.debugRenderPhaseSideEffectsForStrictMode = false;
612-
ReactDOM = require('react-dom');
613-
Scheduler = require('scheduler');
614-
});
615-
616-
it('wont yield during a render if yielding is disabled', () => {
617-
class A extends React.Component {
618-
render() {
619-
Scheduler.yieldValue('A');
620-
return <div>{this.props.children}</div>;
621-
}
622-
}
623-
624-
class B extends React.Component {
625-
render() {
626-
Scheduler.yieldValue('B');
627-
return <div>{this.props.children}</div>;
628-
}
629-
}
630-
631-
class C extends React.Component {
632-
render() {
633-
Scheduler.yieldValue('C');
634-
return <div>{this.props.children}</div>;
635-
}
636-
}
637-
638-
let root = ReactDOM.unstable_createRoot(container);
639-
640-
root.render(
641-
<Fragment>
642-
<A />
643-
<B />
644-
<C />
645-
</Fragment>,
646-
);
647-
648-
expect(Scheduler).toHaveYielded([]);
649-
650-
Scheduler.unstable_flushNumberOfYields(2);
651-
// Even though we just flushed two yields, we should have rendered
652-
// everything without yielding when the flag is on.
653-
expect(Scheduler).toHaveYielded(['A', 'B', 'C']);
654-
});
655-
656-
it('wont suspend during a render if yielding is disabled', () => {
657-
let p = new Promise(resolve => {});
658-
659-
function Suspend() {
660-
throw p;
661-
}
662-
663-
let root = ReactDOM.unstable_createRoot(container);
664-
root.render(
665-
<React.Suspense fallback={'Loading'}>Initial</React.Suspense>,
666-
);
667-
668-
Scheduler.flushAll();
669-
expect(container.textContent).toBe('Initial');
670-
671-
root.render(
672-
<React.Suspense fallback={'Loading'}>
673-
<Suspend />
674-
</React.Suspense>,
675-
);
676-
677-
expect(Scheduler).toHaveYielded([]);
678-
679-
Scheduler.flushAll();
680-
681-
// This should have flushed to the DOM even though we haven't ran the timers.
682-
expect(container.textContent).toBe('Loading');
683-
});
684-
});
685604
});

packages/react-reconciler/src/ReactFiberWorkLoop.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
enableSuspenseServerRenderer,
2424
replayFailedUnitOfWorkWithInvokeGuardedCallback,
2525
enableProfilerTimer,
26-
disableYielding,
2726
enableSchedulerTracing,
2827
revertPassiveEffectsChange,
2928
} from 'shared/ReactFeatureFlags';
@@ -1004,7 +1003,7 @@ function renderRoot(
10041003
// possible.
10051004
const hasNotProcessedNewUpdates =
10061005
workInProgressRootLatestProcessedExpirationTime === Sync;
1007-
if (hasNotProcessedNewUpdates && !disableYielding && !isSync) {
1006+
if (hasNotProcessedNewUpdates && !isSync) {
10081007
// If we have not processed any new updates during this pass, then this is
10091008
// either a retry of an existing fallback state or a hidden tree.
10101009
// Hidden trees shouldn't be batched with other work and after that's
@@ -1041,7 +1040,7 @@ function renderRoot(
10411040
return commitRoot.bind(null, root);
10421041
}
10431042
case RootSuspendedWithDelay: {
1044-
if (!disableYielding && !isSync) {
1043+
if (!isSync) {
10451044
// We're suspended in a state that should be avoided. We'll try to avoid committing
10461045
// it for as long as the timeouts let us.
10471046
if (workInProgressRootHasPendingPing) {
@@ -2147,11 +2146,6 @@ function computeMsUntilSuspenseLoadingDelay(
21472146
committedExpirationTime: ExpirationTime,
21482147
suspenseConfig: SuspenseConfig,
21492148
) {
2150-
if (disableYielding) {
2151-
// Timeout immediately when yielding is disabled.
2152-
return 0;
2153-
}
2154-
21552149
const busyMinDurationMs = (suspenseConfig.busyMinDurationMs: any) | 0;
21562150
if (busyMinDurationMs <= 0) {
21572151
return 0;

packages/react-reconciler/src/SchedulerWithReactIntegration.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111
// CommonJS interop named imports.
1212
import * as Scheduler from 'scheduler';
1313
import {__interactionsRef} from 'scheduler/tracing';
14-
import {
15-
disableYielding,
16-
enableSchedulerTracing,
17-
} from 'shared/ReactFeatureFlags';
14+
import {enableSchedulerTracing} from 'shared/ReactFeatureFlags';
1815
import invariant from 'shared/invariant';
1916

2017
const {
@@ -65,9 +62,7 @@ export const IdlePriority: ReactPriorityLevel = 95;
6562
// NoPriority is the absence of priority. Also React-only.
6663
export const NoPriority: ReactPriorityLevel = 90;
6764

68-
export const shouldYield = disableYielding
69-
? () => false // Never yield when `disableYielding` is on
70-
: Scheduler_shouldYield;
65+
export const shouldYield = Scheduler_shouldYield;
7166

7267
let syncQueue: Array<SchedulerCallback> | null = null;
7368
let immediateQueueCallbackNode: mixed | null = null;

packages/shared/ReactFeatureFlags.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ export function addUserTimingListener() {
4545
// Disable javascript: URL strings in href for XSS protection.
4646
export const disableJavaScriptURLs = false;
4747

48-
// Disables yielding during render in Concurrent Mode. Used for debugging only.
49-
export const disableYielding = false;
50-
5148
// React Fire: prevent the value and checked attributes from syncing
5249
// with their related DOM properties
5350
export const disableInputAttributeSyncing = false;

packages/shared/forks/ReactFeatureFlags.native-fb.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export const warnAboutShorthandPropertyCollision = false;
2727
export const enableSchedulerDebugging = false;
2828
export const debugRenderPhaseSideEffectsForStrictMode = true;
2929
export const disableJavaScriptURLs = false;
30-
export const disableYielding = false;
3130
export const disableInputAttributeSyncing = false;
3231
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
3332
export const warnAboutDeprecatedLifecycles = true;

packages/shared/forks/ReactFeatureFlags.native-oss.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export const enableProfilerTimer = __PROFILE__;
2121
export const enableSchedulerTracing = __PROFILE__;
2222
export const enableSuspenseServerRenderer = false;
2323
export const disableJavaScriptURLs = false;
24-
export const disableYielding = false;
2524
export const disableInputAttributeSyncing = false;
2625
export const enableStableConcurrentModeAPIs = false;
2726
export const warnAboutShorthandPropertyCollision = false;

packages/shared/forks/ReactFeatureFlags.persistent.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export const enableProfilerTimer = __PROFILE__;
2121
export const enableSchedulerTracing = __PROFILE__;
2222
export const enableSuspenseServerRenderer = false;
2323
export const disableJavaScriptURLs = false;
24-
export const disableYielding = false;
2524
export const disableInputAttributeSyncing = false;
2625
export const enableStableConcurrentModeAPIs = false;
2726
export const warnAboutShorthandPropertyCollision = false;

packages/shared/forks/ReactFeatureFlags.test-renderer.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export const enableProfilerTimer = false;
2121
export const enableSchedulerTracing = false;
2222
export const enableSuspenseServerRenderer = false;
2323
export const disableJavaScriptURLs = false;
24-
export const disableYielding = false;
2524
export const disableInputAttributeSyncing = false;
2625
export const enableStableConcurrentModeAPIs = false;
2726
export const warnAboutShorthandPropertyCollision = false;

packages/shared/forks/ReactFeatureFlags.test-renderer.www.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export const enableStableConcurrentModeAPIs = false;
2727
export const enableSchedulerDebugging = false;
2828
export const warnAboutDeprecatedSetNativeProps = false;
2929
export const disableJavaScriptURLs = false;
30-
export const disableYielding = false;
3130
export const enableEventAPI = true;
3231
export const enableJSXTransformAPI = true;
3332
export const warnAboutMissingMockScheduler = true;

packages/shared/forks/ReactFeatureFlags.www.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export const {
1616
debugRenderPhaseSideEffectsForStrictMode,
1717
replayFailedUnitOfWorkWithInvokeGuardedCallback,
1818
warnAboutDeprecatedLifecycles,
19-
disableYielding,
2019
disableInputAttributeSyncing,
2120
warnAboutShorthandPropertyCollision,
2221
warnAboutDeprecatedSetNativeProps,

0 commit comments

Comments
 (0)