Skip to content

Commit cfd6b07

Browse files
committed
Land enableSelectiveHydration flag
This flag is already enabled on all relevant surfaces. We can remove it.
1 parent 4175f05 commit cfd6b07

10 files changed

+43
-59
lines changed

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

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
// -----------------------------------------------------------------------------
1515

1616
export const enableSuspenseServerRenderer = true;
17-
export const enableSelectiveHydration = true;
1817
export const warnAboutDeprecatedLifecycles = true;
1918
export const enableLazyElements = true;
2019
export const enableComponentStackLocations = true;

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 enableProfilerNestedUpdatePhase = __PROFILE__;
2727
export const enableProfilerNestedUpdateScheduledHook = false;
2828
export const enableUpdaterTracking = __PROFILE__;
2929
export const enableSuspenseServerRenderer = false;
30-
export const enableSelectiveHydration = false;
3130
export const enableLazyElements = false;
3231
export const enableCache = false;
3332
export const enableCacheElement = 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 enableProfilerNestedUpdatePhase = __PROFILE__;
2121
export const enableProfilerNestedUpdateScheduledHook = false;
2222
export const enableUpdaterTracking = __PROFILE__;
2323
export const enableSuspenseServerRenderer = false;
24-
export const enableSelectiveHydration = false;
2524
export const enableLazyElements = false;
2625
export const enableCache = false;
2726
export const enableCacheElement = 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 enableProfilerNestedUpdatePhase = __PROFILE__;
2121
export const enableProfilerNestedUpdateScheduledHook = false;
2222
export const enableUpdaterTracking = false;
2323
export const enableSuspenseServerRenderer = false;
24-
export const enableSelectiveHydration = false;
2524
export const enableLazyElements = false;
2625
export const enableCache = __EXPERIMENTAL__;
2726
export const enableCacheElement = __EXPERIMENTAL__;

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export const enableProfilerNestedUpdatePhase = __PROFILE__;
2121
export const enableProfilerNestedUpdateScheduledHook = false;
2222
export const enableUpdaterTracking = false;
2323
export const enableSuspenseServerRenderer = false;
24-
export const enableSelectiveHydration = false;
2524
export const enableLazyElements = false;
2625
export const enableCache = true;
2726
export const enableCacheElement = true;

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export const enableProfilerNestedUpdatePhase = __PROFILE__;
2121
export const enableProfilerNestedUpdateScheduledHook = false;
2222
export const enableUpdaterTracking = false;
2323
export const enableSuspenseServerRenderer = false;
24-
export const enableSelectiveHydration = false;
2524
export const enableLazyElements = false;
2625
export const enableCache = true;
2726
export const enableCacheElement = true;

packages/shared/forks/ReactFeatureFlags.testing.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export const enableProfilerNestedUpdatePhase = __PROFILE__;
2121
export const enableProfilerNestedUpdateScheduledHook = false;
2222
export const enableUpdaterTracking = false;
2323
export const enableSuspenseServerRenderer = false;
24-
export const enableSelectiveHydration = false;
2524
export const enableLazyElements = false;
2625
export const enableCache = __EXPERIMENTAL__;
2726
export const enableCacheElement = __EXPERIMENTAL__;

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export const enableProfilerNestedUpdatePhase = false;
2121
export const enableProfilerNestedUpdateScheduledHook = false;
2222
export const enableUpdaterTracking = false;
2323
export const enableSuspenseServerRenderer = true;
24-
export const enableSelectiveHydration = true;
2524
export const enableLazyElements = false;
2625
export const enableCache = true;
2726
export const enableCacheElement = true;

packages/shared/forks/ReactFeatureFlags.www.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ export const warnAboutStringRefs = false;
6868
export const warnAboutDefaultPropsOnFunctionComponents = false;
6969
export const enableGetInspectorDataForInstanceInProduction = false;
7070
export const enableSuspenseServerRenderer = true;
71-
export const enableSelectiveHydration = true;
7271

7372
export const enableLazyElements = true;
7473
export const enableCache = true;

0 commit comments

Comments
 (0)