@samitouri / QOS-React-2 / commits / 354772952a

Land enableSelectiveHydration flag (#24406)

This flag is already enabled on all relevant surfaces. We can remove it.

Andrew Clark committed Apr 20, 2022 at 10:26 UTC 354772952a8228255cc7e8e32906e427e5255c30
10 files changed +43 -59
packages/react-dom/src/events/ReactDOMEventReplaying.js
+43 -50
@@ -14,10 +14,7 @@ import type {EventSystemFlags} from './EventSystemFlags';
14 import type {FiberRoot} from 'react-reconciler/src/ReactInternalTypes';
15 import type {EventPriority} from 'react-reconciler/src/ReactEventPriorities';
16
17 -import {
18 - enableSelectiveHydration,
19 - enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay,
20 -} from 'shared/ReactFeatureFlags';
17 +import {enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay} from 'shared/ReactFeatureFlags';
18 import {
19 unstable_scheduleCallback as scheduleCallback,
20 unstable_NormalPriority as NormalPriority,
@@ -204,27 +201,25 @@ export function queueDiscreteEvent(
201 nativeEvent,
202 );
203 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;
223 }
224 }
225 }
@@ -428,33 +423,31 @@ function attemptExplicitHydrationTarget(
423 }
424
425 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;
445 }
446 }
447 + queuedExplicitHydrationTargets.splice(i, 0, queuedTarget);
448 + if (i === 0) {
449 + attemptExplicitHydrationTarget(queuedTarget);
450 + }
451 }
452
453 function attemptReplayContinuousQueuedEvent(
packages/shared/ReactFeatureFlags.js
-1
@@ -13,7 +13,6 @@
13 // Flags that can likely be deleted or landed without consequences
14 // -----------------------------------------------------------------------------
15
16 -export const enableSelectiveHydration = true;
16 export const warnAboutDeprecatedLifecycles = true;
17 export const enableComponentStackLocations = true;
18 export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
packages/shared/forks/ReactFeatureFlags.native-fb.js
-1
@@ -26,7 +26,6 @@ export const enableProfilerCommitHooks = __PROFILE__;
26 export const enableProfilerNestedUpdatePhase = __PROFILE__;
27 export const enableProfilerNestedUpdateScheduledHook = false;
28 export const enableUpdaterTracking = __PROFILE__;
29 -export const enableSelectiveHydration = false;
29 export const enableCache = false;
30 export const enableCacheElement = true;
31 export const enableSchedulerDebugging = false;
packages/shared/forks/ReactFeatureFlags.native-oss.js
-1
@@ -20,7 +20,6 @@ export const enableProfilerCommitHooks = __PROFILE__;
20 export const enableProfilerNestedUpdatePhase = __PROFILE__;
21 export const enableProfilerNestedUpdateScheduledHook = false;
22 export const enableUpdaterTracking = __PROFILE__;
23 -export const enableSelectiveHydration = false;
23 export const enableCache = false;
24 export const enableCacheElement = false;
25 export const disableJavaScriptURLs = false;
packages/shared/forks/ReactFeatureFlags.test-renderer.js
-1
@@ -20,7 +20,6 @@ export const enableProfilerCommitHooks = __PROFILE__;
20 export const enableProfilerNestedUpdatePhase = __PROFILE__;
21 export const enableProfilerNestedUpdateScheduledHook = false;
22 export const enableUpdaterTracking = false;
23 -export const enableSelectiveHydration = false;
23 export const enableCache = __EXPERIMENTAL__;
24 export const enableCacheElement = __EXPERIMENTAL__;
25 export const disableJavaScriptURLs = false;
packages/shared/forks/ReactFeatureFlags.test-renderer.native.js
-1
@@ -20,7 +20,6 @@ export const enableProfilerCommitHooks = __PROFILE__;
20 export const enableProfilerNestedUpdatePhase = __PROFILE__;
21 export const enableProfilerNestedUpdateScheduledHook = false;
22 export const enableUpdaterTracking = false;
23 -export const enableSelectiveHydration = false;
23 export const enableCache = true;
24 export const enableCacheElement = true;
25 export const disableJavaScriptURLs = false;
packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
-1
@@ -20,7 +20,6 @@ export const enableProfilerCommitHooks = __PROFILE__;
20 export const enableProfilerNestedUpdatePhase = __PROFILE__;
21 export const enableProfilerNestedUpdateScheduledHook = false;
22 export const enableUpdaterTracking = false;
23 -export const enableSelectiveHydration = false;
23 export const enableCache = true;
24 export const enableCacheElement = true;
25 export const enableSchedulerDebugging = false;
packages/shared/forks/ReactFeatureFlags.testing.js
-1
@@ -20,7 +20,6 @@ export const enableProfilerCommitHooks = __PROFILE__;
20 export const enableProfilerNestedUpdatePhase = __PROFILE__;
21 export const enableProfilerNestedUpdateScheduledHook = false;
22 export const enableUpdaterTracking = false;
23 -export const enableSelectiveHydration = false;
23 export const enableCache = __EXPERIMENTAL__;
24 export const enableCacheElement = __EXPERIMENTAL__;
25 export const disableJavaScriptURLs = false;
packages/shared/forks/ReactFeatureFlags.testing.www.js
-1
@@ -20,7 +20,6 @@ export const enableProfilerCommitHooks = false;
20 export const enableProfilerNestedUpdatePhase = false;
21 export const enableProfilerNestedUpdateScheduledHook = false;
22 export const enableUpdaterTracking = false;
23 -export const enableSelectiveHydration = true;
23 export const enableCache = true;
24 export const enableCacheElement = true;
25 export const disableJavaScriptURLs = true;
packages/shared/forks/ReactFeatureFlags.www.js
-1
@@ -67,7 +67,6 @@ export const disableLegacyContext = __EXPERIMENTAL__;
67 export const warnAboutStringRefs = false;
68 export const warnAboutDefaultPropsOnFunctionComponents = false;
69 export const enableGetInspectorDataForInstanceInProduction = false;
70 -export const enableSelectiveHydration = true;
70
71 export const enableCache = true;
72 export const enableCacheElement = true;