@samitouri / QOS-React-2 / commits / 766af5968a

Move Scope API ref resolution to mutation phase (#19264)

* Move Scope API ref resolution to mutation phase

Dominic Gannaway committed Jul 8, 2020 at 23:41 UTC 766af5968a77c33cc1af0432247d678680bb7b19
2 files changed +38 -4
packages/react-reconciler/src/ReactFiberWorkLoop.new.js
+19 -2
@@ -27,6 +27,7 @@ import {
27 warnAboutUnmockedScheduler,
28 deferRenderPhaseUpdateToNextBatch,
29 decoupleUpdatePriorityFromScheduler,
30 + enableScopeAPI,
31 } from 'shared/ReactFeatureFlags';
32 import ReactSharedInternals from 'shared/ReactSharedInternals';
33 import invariant from 'shared/invariant';
@@ -88,6 +89,7 @@ import {
89 Block,
90 OffscreenComponent,
91 LegacyHiddenComponent,
92 + ScopeComponent,
93 } from './ReactWorkTags';
94 import {LegacyRoot} from './ReactRootTags';
95 import {
@@ -2217,6 +2219,13 @@ function commitMutationEffects(root: FiberRoot, renderPriorityLevel) {
2219 if (current !== null) {
2220 commitDetachRef(current);
2221 }
2222 + if (enableScopeAPI) {
2223 + // TODO: This is a temporary solution that allows us to transition away
2224 + // from React Flare on www.
2225 + if (nextEffect.tag === ScopeComponent) {
2226 + commitAttachRef(nextEffect);
2227 + }
2228 + }
2229 }
2230
2231 // The following switch statement is only concerned about placement,
@@ -2287,8 +2296,16 @@ function commitLayoutEffects(root: FiberRoot, committedLanes: Lanes) {
2296 commitLayoutEffectOnFiber(root, current, nextEffect, committedLanes);
2297 }
2298
2290 - if (effectTag & Ref) {
2291 - commitAttachRef(nextEffect);
2299 + if (enableScopeAPI) {
2300 + // TODO: This is a temporary solution that allows us to transition away
2301 + // from React Flare on www.
2302 + if (effectTag & Ref && nextEffect.tag !== ScopeComponent) {
2303 + commitAttachRef(nextEffect);
2304 + }
2305 + } else {
2306 + if (effectTag & Ref) {
2307 + commitAttachRef(nextEffect);
2308 + }
2309 }
2310
2311 resetCurrentDebugFiberInDEV();
packages/react-reconciler/src/ReactFiberWorkLoop.old.js
+19 -2
@@ -29,6 +29,7 @@ import {
29 decoupleUpdatePriorityFromScheduler,
30 enableDebugTracing,
31 enableSchedulingProfiler,
32 + enableScopeAPI,
33 } from 'shared/ReactFeatureFlags';
34 import ReactSharedInternals from 'shared/ReactSharedInternals';
35 import invariant from 'shared/invariant';
@@ -111,6 +112,7 @@ import {
112 Block,
113 OffscreenComponent,
114 LegacyHiddenComponent,
115 + ScopeComponent,
116 } from './ReactWorkTags';
117 import {LegacyRoot} from './ReactRootTags';
118 import {
@@ -2324,6 +2326,13 @@ function commitMutationEffects(root: FiberRoot, renderPriorityLevel) {
2326 if (current !== null) {
2327 commitDetachRef(current);
2328 }
2329 + if (enableScopeAPI) {
2330 + // TODO: This is a temporary solution that allows us to transition away
2331 + // from React Flare on www.
2332 + if (nextEffect.tag === ScopeComponent) {
2333 + commitAttachRef(nextEffect);
2334 + }
2335 + }
2336 }
2337
2338 // The following switch statement is only concerned about placement,
@@ -2404,8 +2413,16 @@ function commitLayoutEffects(root: FiberRoot, committedLanes: Lanes) {
2413 commitLayoutEffectOnFiber(root, current, nextEffect, committedLanes);
2414 }
2415
2407 - if (effectTag & Ref) {
2408 - commitAttachRef(nextEffect);
2416 + if (enableScopeAPI) {
2417 + // TODO: This is a temporary solution that allows us to transition away
2418 + // from React Flare on www.
2419 + if (effectTag & Ref && nextEffect.tag !== ScopeComponent) {
2420 + commitAttachRef(nextEffect);
2421 + }
2422 + } else {
2423 + if (effectTag & Ref) {
2424 + commitAttachRef(nextEffect);
2425 + }
2426 }
2427
2428 resetCurrentDebugFiberInDEV();