Skip to content

Commit 3547729

Browse files
authored
Land enableSelectiveHydration flag (#24406)
This flag is already enabled on all relevant surfaces. We can remove it.
1 parent 392808a commit 3547729

10 files changed

+43
-59
lines changed

packages/react-dom/src/events/ReactDOMEventReplaying.js

+43-50
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ import type {EventSystemFlags} from './EventSystemFlags';
1414
import type {FiberRoot} from 'react-reconciler/src/ReactInternalTypes';
1515
import type {EventPriority} from 'react-reconciler/src/ReactEventPriorities';
1616

17-
import {
18-
enableSelectiveHydration,
19-
enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay,
20-
} from 'shared/ReactFeatureFlags';
17+
import {enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay} from 'shared/ReactFeatureFlags';
2118
import {
2219
unstable_scheduleCallback as scheduleCallback,
2320
unstable_NormalPriority as NormalPriority,
@@ -204,27 +201,25 @@ export function queueDiscreteEvent(
204201
nativeEvent,
205202
);
206203
queuedDiscreteEvents.push(queuedEvent);
207-
if (enableSelectiveHydration) {
208-
if (queuedDiscreteEvents.length === 1) {
209-
// If this was the first discrete event, we might be able to
210-
// synchronously unblock it so that preventDefault still works.
211-
while (queuedEvent.blockedOn !== null) {
212-
const fiber = getInstanceFromNode(queuedEvent.blockedOn);
213-
if (fiber === null) {
214-
break;
215-
}
216-
attemptSynchronousHydration(fiber);
217-
if (queuedEvent.blockedOn === null) {
218-
// We got unblocked by hydration. Let's try again.
219-
replayUnblockedEvents();
220-
// If we're reblocked, on an inner boundary, we might need
221-
// to attempt hydrating that one.
222-
continue;
223-
} else {
224-
// We're still blocked from hydration, we have to give up
225-
// and replay later.
226-
break;
227-
}
204+
if (queuedDiscreteEvents.length === 1) {
205+
// If this was the first discrete event, we might be able to
206+
// synchronously unblock it so that preventDefault still works.
207+
while (queuedEvent.blockedOn !== null) {
208+
const fiber = getInstanceFromNode(queuedEvent.blockedOn);
209+
if (fiber === null) {
210+
break;
211+
}
212+
attemptSynchronousHydration(fiber);
213+
if (queuedEvent.blockedOn === null) {
214+
// We got unblocked by hydration. Let's try again.
215+
replayUnblockedEvents();
216+
// If we're reblocked, on an inner boundary, we might need
217+
// to attempt hydrating that one.
218+
continue;
219+
} else {
220+
// We're still blocked from hydration, we have to give up
221+
// and replay later.
222+
break;
228223
}
229224
}
230225
}
@@ -428,33 +423,31 @@ function attemptExplicitHydrationTarget(
428423
}
429424

430425
export function queueExplicitHydrationTarget(target: Node): void {
431-
if (enableSelectiveHydration) {
432-
// TODO: This will read the priority if it's dispatched by the React
433-
// event system but not native events. Should read window.event.type, like
434-
// we do for updates (getCurrentEventPriority).
435-
const updatePriority = getCurrentUpdatePriority();
436-
const queuedTarget: QueuedHydrationTarget = {
437-
blockedOn: null,
438-
target: target,
439-
priority: updatePriority,
440-
};
441-
let i = 0;
442-
for (; i < queuedExplicitHydrationTargets.length; i++) {
443-
// Stop once we hit the first target with lower priority than
444-
if (
445-
!isHigherEventPriority(
446-
updatePriority,
447-
queuedExplicitHydrationTargets[i].priority,
448-
)
449-
) {
450-
break;
451-
}
452-
}
453-
queuedExplicitHydrationTargets.splice(i, 0, queuedTarget);
454-
if (i === 0) {
455-
attemptExplicitHydrationTarget(queuedTarget);
426+
// TODO: This will read the priority if it's dispatched by the React
427+
// event system but not native events. Should read window.event.type, like
428+
// we do for updates (getCurrentEventPriority).
429+
const updatePriority = getCurrentUpdatePriority();
430+
const queuedTarget: QueuedHydrationTarget = {
431+
blockedOn: null,
432+
target: target,
433+
priority: updatePriority,
434+
};
435+
let i = 0;
436+
for (; i < queuedExplicitHydrationTargets.length; i++) {
437+
// Stop once we hit the first target with lower priority than
438+
if (
439+
!isHigherEventPriority(
440+
updatePriority,
441+
queuedExplicitHydrationTargets[i].priority,
442+
)
443+
) {
444+
break;
456445
}
457446
}
447+
queuedExplicitHydrationTargets.splice(i, 0, queuedTarget);
448+
if (i === 0) {
449+
attemptExplicitHydrationTarget(queuedTarget);
450+
}
458451
}
459452

460453
function attemptReplayContinuousQueuedEvent(

packages/shared/ReactFeatureFlags.js

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
// Flags that can likely be deleted or landed without consequences
1414
// -----------------------------------------------------------------------------
1515

16-
export const enableSelectiveHydration = true;
1716
export const warnAboutDeprecatedLifecycles = true;
1817
export const enableComponentStackLocations = true;
1918
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;

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

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export const enableProfilerCommitHooks = __PROFILE__;
2626
export const enableProfilerNestedUpdatePhase = __PROFILE__;
2727
export const enableProfilerNestedUpdateScheduledHook = false;
2828
export const enableUpdaterTracking = __PROFILE__;
29-
export const enableSelectiveHydration = false;
3029
export const enableCache = false;
3130
export const enableCacheElement = true;
3231
export const enableSchedulerDebugging = false;

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

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export const enableProfilerCommitHooks = __PROFILE__;
2020
export const enableProfilerNestedUpdatePhase = __PROFILE__;
2121
export const enableProfilerNestedUpdateScheduledHook = false;
2222
export const enableUpdaterTracking = __PROFILE__;
23-
export const enableSelectiveHydration = false;
2423
export const enableCache = false;
2524
export const enableCacheElement = false;
2625
export const disableJavaScriptURLs = false;

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

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export const enableProfilerCommitHooks = __PROFILE__;
2020
export const enableProfilerNestedUpdatePhase = __PROFILE__;
2121
export const enableProfilerNestedUpdateScheduledHook = false;
2222
export const enableUpdaterTracking = false;
23-
export const enableSelectiveHydration = false;
2423
export const enableCache = __EXPERIMENTAL__;
2524
export const enableCacheElement = __EXPERIMENTAL__;
2625
export const disableJavaScriptURLs = false;

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

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export const enableProfilerCommitHooks = __PROFILE__;
2020
export const enableProfilerNestedUpdatePhase = __PROFILE__;
2121
export const enableProfilerNestedUpdateScheduledHook = false;
2222
export const enableUpdaterTracking = false;
23-
export const enableSelectiveHydration = false;
2423
export const enableCache = true;
2524
export const enableCacheElement = true;
2625
export const disableJavaScriptURLs = false;

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

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export const enableProfilerCommitHooks = __PROFILE__;
2020
export const enableProfilerNestedUpdatePhase = __PROFILE__;
2121
export const enableProfilerNestedUpdateScheduledHook = false;
2222
export const enableUpdaterTracking = false;
23-
export const enableSelectiveHydration = false;
2423
export const enableCache = true;
2524
export const enableCacheElement = true;
2625
export const enableSchedulerDebugging = false;

packages/shared/forks/ReactFeatureFlags.testing.js

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export const enableProfilerCommitHooks = __PROFILE__;
2020
export const enableProfilerNestedUpdatePhase = __PROFILE__;
2121
export const enableProfilerNestedUpdateScheduledHook = false;
2222
export const enableUpdaterTracking = false;
23-
export const enableSelectiveHydration = false;
2423
export const enableCache = __EXPERIMENTAL__;
2524
export const enableCacheElement = __EXPERIMENTAL__;
2625
export const disableJavaScriptURLs = false;

packages/shared/forks/ReactFeatureFlags.testing.www.js

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export const enableProfilerCommitHooks = false;
2020
export const enableProfilerNestedUpdatePhase = false;
2121
export const enableProfilerNestedUpdateScheduledHook = false;
2222
export const enableUpdaterTracking = false;
23-
export const enableSelectiveHydration = true;
2423
export const enableCache = true;
2524
export const enableCacheElement = true;
2625
export const disableJavaScriptURLs = true;

packages/shared/forks/ReactFeatureFlags.www.js

-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ export const disableLegacyContext = __EXPERIMENTAL__;
6767
export const warnAboutStringRefs = false;
6868
export const warnAboutDefaultPropsOnFunctionComponents = false;
6969
export const enableGetInspectorDataForInstanceInProduction = false;
70-
export const enableSelectiveHydration = true;
7170

7271
export const enableCache = true;
7372
export const enableCacheElement = true;

0 commit comments

Comments
 (0)