Skip to content

Commit 72a933d

Browse files
authored
Gate legacy hidden (#24047)
* Gate legacy hidden * Gate tests * Remove export from experimental
1 parent b9de50d commit 72a933d

29 files changed

+175
-136
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -3197,7 +3197,7 @@ describe('ReactDOMServerPartialHydration', () => {
31973197
expect(span.innerHTML).toBe('Hidden child');
31983198
});
31993199

3200-
// @gate experimental || www
3200+
// @gate www
32013201
it('renders a hidden LegacyHidden component inside a Suspense boundary', async () => {
32023202
const ref = React.createRef();
32033203

@@ -3225,7 +3225,7 @@ describe('ReactDOMServerPartialHydration', () => {
32253225
expect(span.innerHTML).toBe('Hidden child');
32263226
});
32273227

3228-
// @gate experimental || www
3228+
// @gate www
32293229
it('renders a visible LegacyHidden component', async () => {
32303230
const ref = React.createRef();
32313231

packages/react-dom/src/__tests__/ReactUpdates-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,7 @@ describe('ReactUpdates', () => {
13021302
expect(ops).toEqual(['Foo', 'Bar', 'Baz']);
13031303
});
13041304

1305-
// @gate experimental || www
1305+
// @gate www
13061306
it('delays sync updates inside hidden subtrees in Concurrent Mode', () => {
13071307
const container = document.createElement('div');
13081308

packages/react-reconciler/src/ReactFiber.new.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
enableStrictEffects,
2424
enableProfilerTimer,
2525
enableScopeAPI,
26+
enableLegacyHidden,
2627
enableSyncDefaultUpdates,
2728
allowConcurrentByDefault,
2829
enableTransitionTracing,
@@ -510,7 +511,10 @@ export function createFiberFromTypeAndProps(
510511
case REACT_OFFSCREEN_TYPE:
511512
return createFiberFromOffscreen(pendingProps, mode, lanes, key);
512513
case REACT_LEGACY_HIDDEN_TYPE:
513-
return createFiberFromLegacyHidden(pendingProps, mode, lanes, key);
514+
if (enableLegacyHidden) {
515+
return createFiberFromLegacyHidden(pendingProps, mode, lanes, key);
516+
}
517+
// eslint-disable-next-line no-fallthrough
514518
case REACT_SCOPE_TYPE:
515519
if (enableScopeAPI) {
516520
return createFiberFromScope(type, pendingProps, mode, lanes, key);

packages/react-reconciler/src/ReactFiber.old.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
enableStrictEffects,
2424
enableProfilerTimer,
2525
enableScopeAPI,
26+
enableLegacyHidden,
2627
enableSyncDefaultUpdates,
2728
allowConcurrentByDefault,
2829
enableTransitionTracing,
@@ -510,7 +511,10 @@ export function createFiberFromTypeAndProps(
510511
case REACT_OFFSCREEN_TYPE:
511512
return createFiberFromOffscreen(pendingProps, mode, lanes, key);
512513
case REACT_LEGACY_HIDDEN_TYPE:
513-
return createFiberFromLegacyHidden(pendingProps, mode, lanes, key);
514+
if (enableLegacyHidden) {
515+
return createFiberFromLegacyHidden(pendingProps, mode, lanes, key);
516+
}
517+
// eslint-disable-next-line no-fallthrough
514518
case REACT_SCOPE_TYPE:
515519
if (enableScopeAPI) {
516520
return createFiberFromScope(type, pendingProps, mode, lanes, key);

packages/react-reconciler/src/ReactFiberBeginWork.new.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ import {
9898
enableSchedulingProfiler,
9999
enablePersistentOffscreenHostContainer,
100100
enableTransitionTracing,
101+
enableLegacyHidden,
101102
} from 'shared/ReactFeatureFlags';
102103
import isArray from 'shared/isArray';
103104
import shallowEqual from 'shared/shallowEqual';
@@ -640,7 +641,7 @@ function updateOffscreenComponent(
640641

641642
if (
642643
nextProps.mode === 'hidden' ||
643-
nextProps.mode === 'unstable-defer-without-hiding'
644+
(enableLegacyHidden && nextProps.mode === 'unstable-defer-without-hiding')
644645
) {
645646
// Rendering a hidden tree.
646647
if ((workInProgress.mode & ConcurrentMode) === NoMode) {
@@ -774,7 +775,7 @@ function updateOffscreenComponent(
774775
// or some other infra that expects a HostComponent.
775776
const isHidden =
776777
nextProps.mode === 'hidden' &&
777-
workInProgress.tag !== LegacyHiddenComponent;
778+
(!enableLegacyHidden || workInProgress.tag !== LegacyHiddenComponent);
778779
const offscreenContainer = reconcileOffscreenHostContainer(
779780
current,
780781
workInProgress,
@@ -3948,7 +3949,14 @@ function beginWork(
39483949
return updateOffscreenComponent(current, workInProgress, renderLanes);
39493950
}
39503951
case LegacyHiddenComponent: {
3951-
return updateLegacyHiddenComponent(current, workInProgress, renderLanes);
3952+
if (enableLegacyHidden) {
3953+
return updateLegacyHiddenComponent(
3954+
current,
3955+
workInProgress,
3956+
renderLanes,
3957+
);
3958+
}
3959+
break;
39523960
}
39533961
case CacheComponent: {
39543962
if (enableCache) {

packages/react-reconciler/src/ReactFiberBeginWork.old.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ import {
9898
enableSchedulingProfiler,
9999
enablePersistentOffscreenHostContainer,
100100
enableTransitionTracing,
101+
enableLegacyHidden,
101102
} from 'shared/ReactFeatureFlags';
102103
import isArray from 'shared/isArray';
103104
import shallowEqual from 'shared/shallowEqual';
@@ -640,7 +641,7 @@ function updateOffscreenComponent(
640641

641642
if (
642643
nextProps.mode === 'hidden' ||
643-
nextProps.mode === 'unstable-defer-without-hiding'
644+
(enableLegacyHidden && nextProps.mode === 'unstable-defer-without-hiding')
644645
) {
645646
// Rendering a hidden tree.
646647
if ((workInProgress.mode & ConcurrentMode) === NoMode) {
@@ -774,7 +775,7 @@ function updateOffscreenComponent(
774775
// or some other infra that expects a HostComponent.
775776
const isHidden =
776777
nextProps.mode === 'hidden' &&
777-
workInProgress.tag !== LegacyHiddenComponent;
778+
(!enableLegacyHidden || workInProgress.tag !== LegacyHiddenComponent);
778779
const offscreenContainer = reconcileOffscreenHostContainer(
779780
current,
780781
workInProgress,
@@ -3948,7 +3949,14 @@ function beginWork(
39483949
return updateOffscreenComponent(current, workInProgress, renderLanes);
39493950
}
39503951
case LegacyHiddenComponent: {
3951-
return updateLegacyHiddenComponent(current, workInProgress, renderLanes);
3952+
if (enableLegacyHidden) {
3953+
return updateLegacyHiddenComponent(
3954+
current,
3955+
workInProgress,
3956+
renderLanes,
3957+
);
3958+
}
3959+
break;
39523960
}
39533961
case CacheComponent: {
39543962
if (enableCache) {

packages/react-reconciler/src/ReactFiberCompleteWork.new.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import type {Cache} from './ReactFiberCacheComponent.new';
3232
import {
3333
enableClientRenderFallbackOnHydrationMismatch,
3434
enableSuspenseAvoidThisFallback,
35+
enableLegacyHidden,
3536
} from 'shared/ReactFeatureFlags';
3637

3738
import {resetWorkInProgressVersions as resetMutableSourceWorkInProgressVersions} from './ReactMutableSource.new';
@@ -1499,9 +1500,8 @@ function completeWork(
14991500
const prevIsHidden = prevState !== null;
15001501
if (
15011502
prevIsHidden !== nextIsHidden &&
1502-
newProps.mode !== 'unstable-defer-without-hiding' &&
15031503
// LegacyHidden doesn't do any hiding — it only pre-renders.
1504-
workInProgress.tag !== LegacyHiddenComponent
1504+
(!enableLegacyHidden || workInProgress.tag !== LegacyHiddenComponent)
15051505
) {
15061506
workInProgress.flags |= Visibility;
15071507
}
@@ -1519,9 +1519,9 @@ function completeWork(
15191519
// If so, we need to hide those nodes in the commit phase, so
15201520
// schedule a visibility effect.
15211521
if (
1522-
workInProgress.tag !== LegacyHiddenComponent &&
1523-
workInProgress.subtreeFlags & (Placement | Update) &&
1524-
newProps.mode !== 'unstable-defer-without-hiding'
1522+
(!enableLegacyHidden ||
1523+
workInProgress.tag !== LegacyHiddenComponent) &&
1524+
workInProgress.subtreeFlags & (Placement | Update)
15251525
) {
15261526
workInProgress.flags |= Visibility;
15271527
}

packages/react-reconciler/src/ReactFiberCompleteWork.old.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import type {Cache} from './ReactFiberCacheComponent.old';
3232
import {
3333
enableClientRenderFallbackOnHydrationMismatch,
3434
enableSuspenseAvoidThisFallback,
35+
enableLegacyHidden,
3536
} from 'shared/ReactFeatureFlags';
3637

3738
import {resetWorkInProgressVersions as resetMutableSourceWorkInProgressVersions} from './ReactMutableSource.old';
@@ -1499,9 +1500,8 @@ function completeWork(
14991500
const prevIsHidden = prevState !== null;
15001501
if (
15011502
prevIsHidden !== nextIsHidden &&
1502-
newProps.mode !== 'unstable-defer-without-hiding' &&
15031503
// LegacyHidden doesn't do any hiding — it only pre-renders.
1504-
workInProgress.tag !== LegacyHiddenComponent
1504+
(!enableLegacyHidden || workInProgress.tag !== LegacyHiddenComponent)
15051505
) {
15061506
workInProgress.flags |= Visibility;
15071507
}
@@ -1519,9 +1519,9 @@ function completeWork(
15191519
// If so, we need to hide those nodes in the commit phase, so
15201520
// schedule a visibility effect.
15211521
if (
1522-
workInProgress.tag !== LegacyHiddenComponent &&
1523-
workInProgress.subtreeFlags & (Placement | Update) &&
1524-
newProps.mode !== 'unstable-defer-without-hiding'
1522+
(!enableLegacyHidden ||
1523+
workInProgress.tag !== LegacyHiddenComponent) &&
1524+
workInProgress.subtreeFlags & (Placement | Update)
15251525
) {
15261526
workInProgress.flags |= Visibility;
15271527
}

packages/react-reconciler/src/__tests__/ReactContextPropagation-test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ describe('ReactLazyContextPropagation', () => {
546546
expect(root).toMatchRenderedOutput('BB');
547547
});
548548

549-
// @gate experimental || www
549+
// @gate www
550550
test('context is propagated through offscreen trees', async () => {
551551
const LegacyHidden = React.unstable_LegacyHidden;
552552

@@ -592,7 +592,7 @@ describe('ReactLazyContextPropagation', () => {
592592
expect(root).toMatchRenderedOutput('BB');
593593
});
594594

595-
// @gate experimental || www
595+
// @gate www
596596
test('multiple contexts are propagated across through offscreen trees', async () => {
597597
// Same as previous test, but with multiple context providers
598598
const LegacyHidden = React.unstable_LegacyHidden;
@@ -818,7 +818,7 @@ describe('ReactLazyContextPropagation', () => {
818818
expect(root).toMatchRenderedOutput('BB');
819819
});
820820

821-
// @gate experimental || www
821+
// @gate www
822822
test('nested bailouts through offscreen trees', async () => {
823823
// Lazy context propagation will stop propagating when it hits the first
824824
// match. If we bail out again inside that tree, we must resume propagating.

packages/react-reconciler/src/__tests__/ReactIncremental-test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ describe('ReactIncremental', () => {
270270
expect(inst.state).toEqual({text: 'bar', text2: 'baz'});
271271
});
272272

273-
// @gate experimental || www
273+
// @gate www
274274
it('can deprioritize unfinished work and resume it later', () => {
275275
function Bar(props) {
276276
Scheduler.unstable_yieldValue('Bar');
@@ -316,7 +316,7 @@ describe('ReactIncremental', () => {
316316
expect(Scheduler).toFlushAndYield(['Middle', 'Middle']);
317317
});
318318

319-
// @gate experimental || www
319+
// @gate www
320320
it('can deprioritize a tree from without dropping work', () => {
321321
function Bar(props) {
322322
Scheduler.unstable_yieldValue('Bar');
@@ -1999,7 +1999,7 @@ describe('ReactIncremental', () => {
19991999
});
20002000
}
20012001

2002-
// @gate experimental || www
2002+
// @gate www
20032003
it('provides context when reusing work', () => {
20042004
class Intl extends React.Component {
20052005
static childContextTypes = {

packages/react-reconciler/src/__tests__/ReactIncrementalErrorHandling-test.internal.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ describe('ReactIncrementalErrorHandling', () => {
310310
expect(ReactNoop.getChildren()).toEqual([span('Everything is fine.')]);
311311
});
312312

313-
// @gate experimental || www
313+
// @gate www
314314
it('does not include offscreen work when retrying after an error', () => {
315315
function App(props) {
316316
if (props.isBroken) {

packages/react-reconciler/src/__tests__/ReactIncrementalSideEffects-test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ describe('ReactIncrementalSideEffects', () => {
424424
]);
425425
});
426426

427-
// @gate experimental || www
427+
// @gate www
428428
it('preserves a previously rendered node when deprioritized', () => {
429429
function Middle(props) {
430430
Scheduler.unstable_yieldValue('Middle');
@@ -475,7 +475,7 @@ describe('ReactIncrementalSideEffects', () => {
475475
);
476476
});
477477

478-
// @gate experimental || www
478+
// @gate www
479479
it('can reuse side-effects after being preempted', () => {
480480
function Bar(props) {
481481
Scheduler.unstable_yieldValue('Bar');
@@ -555,7 +555,7 @@ describe('ReactIncrementalSideEffects', () => {
555555
);
556556
});
557557

558-
// @gate experimental || www
558+
// @gate www
559559
it('can reuse side-effects after being preempted, if shouldComponentUpdate is false', () => {
560560
class Bar extends React.Component {
561561
shouldComponentUpdate(nextProps) {
@@ -690,7 +690,7 @@ describe('ReactIncrementalSideEffects', () => {
690690
expect(ReactNoop.getChildrenAsJSX()).toEqual(<span prop={3} />);
691691
});
692692

693-
// @gate experimental || www
693+
// @gate www
694694
it('updates a child even though the old props is empty', () => {
695695
function Foo(props) {
696696
return (
@@ -930,7 +930,7 @@ describe('ReactIncrementalSideEffects', () => {
930930
expect(ops).toEqual(['Bar', 'Baz', 'Bar', 'Bar']);
931931
});
932932

933-
// @gate experimental || www
933+
// @gate www
934934
it('deprioritizes setStates that happens within a deprioritized tree', () => {
935935
const barInstances = [];
936936

packages/react-reconciler/src/__tests__/ReactNewContext-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ describe('ReactNewContext', () => {
667667
expect(ReactNoop.getChildren()).toEqual([span(2), span(2)]);
668668
});
669669

670-
// @gate experimental || www
670+
// @gate www
671671
it("context consumer doesn't bail out inside hidden subtree", () => {
672672
const Context = React.createContext('dark');
673673
const Consumer = getConsumer(Context);

packages/react-reconciler/src/__tests__/ReactOffscreen-test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('ReactOffscreen', () => {
2626
return <span prop={props.text} />;
2727
}
2828

29-
// @gate experimental || www
29+
// @gate www
3030
it('unstable-defer-without-hiding should never toggle the visibility of its children', async () => {
3131
function App({mode}) {
3232
return (
@@ -85,7 +85,7 @@ describe('ReactOffscreen', () => {
8585
);
8686
});
8787

88-
// @gate experimental || www
88+
// @gate www
8989
it('does not defer in legacy mode', async () => {
9090
let setState;
9191
function Foo() {
@@ -130,7 +130,7 @@ describe('ReactOffscreen', () => {
130130
);
131131
});
132132

133-
// @gate experimental || www
133+
// @gate www
134134
it('does defer in concurrent mode', async () => {
135135
let setState;
136136
function Foo() {
@@ -310,7 +310,7 @@ describe('ReactOffscreen', () => {
310310
expect(root).toMatchRenderedOutput(<span hidden={true} prop="Child" />);
311311
});
312312

313-
// @gate experimental || www
313+
// @gate www
314314
it('does not toggle effects for LegacyHidden component', async () => {
315315
// LegacyHidden is meant to be the same as offscreen except it doesn't
316316
// do anything to effects. Only used by www, as a temporary migration step.

packages/react-reconciler/src/__tests__/ReactSchedulerIntegration-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ describe('ReactSchedulerIntegration', () => {
122122
expect(Scheduler).toHaveYielded(['A', 'B', 'C']);
123123
});
124124

125-
// @gate experimental || www
125+
// @gate www
126126
it('idle updates are not blocked by offscreen work', async () => {
127127
function Text({text}) {
128128
Scheduler.unstable_yieldValue(text);

packages/react-reconciler/src/__tests__/ReactSuspenseWithNoopRenderer-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3073,7 +3073,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
30733073
expect(root).toMatchRenderedOutput(<span prop="Foo" />);
30743074
});
30753075

3076-
// @gate enableCache
3076+
// @gate enableCache && enableLegacyHidden
30773077
it('should not render hidden content while suspended on higher pri', async () => {
30783078
function Offscreen() {
30793079
Scheduler.unstable_yieldValue('Offscreen');
@@ -3123,7 +3123,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
31233123
);
31243124
});
31253125

3126-
// @gate enableCache
3126+
// @gate enableCache && enableLegacyHidden
31273127
it('should be able to unblock higher pri content before suspended hidden', async () => {
31283128
function Offscreen() {
31293129
Scheduler.unstable_yieldValue('Offscreen');

0 commit comments

Comments
 (0)