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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 5 additions & 1 deletion
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

Lines changed: 5 additions & 1 deletion
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

Lines changed: 11 additions & 3 deletions
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

Lines changed: 11 additions & 3 deletions
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

Lines changed: 5 additions & 5 deletions
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

Lines changed: 5 additions & 5 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 3 additions & 3 deletions
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 = {

0 commit comments

Comments
 (0)