Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Scope API ref resolution to mutation phase #19264

Merged
merged 3 commits into from Jul 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 19 additions & 2 deletions packages/react-reconciler/src/ReactFiberWorkLoop.new.js
Expand Up @@ -27,6 +27,7 @@ import {
warnAboutUnmockedScheduler,
deferRenderPhaseUpdateToNextBatch,
decoupleUpdatePriorityFromScheduler,
enableScopeAPI,
} from 'shared/ReactFeatureFlags';
import ReactSharedInternals from 'shared/ReactSharedInternals';
import invariant from 'shared/invariant';
Expand Down Expand Up @@ -88,6 +89,7 @@ import {
Block,
OffscreenComponent,
LegacyHiddenComponent,
ScopeComponent,
} from './ReactWorkTags';
import {LegacyRoot} from './ReactRootTags';
import {
Expand Down Expand Up @@ -2217,6 +2219,13 @@ function commitMutationEffects(root: FiberRoot, renderPriorityLevel) {
if (current !== null) {
commitDetachRef(current);
}
if (enableScopeAPI) {
// TODO: This is a temporary solution that allows us to transition away
// from React Flare on www.
if (nextEffect.tag === ScopeComponent) {
commitAttachRef(nextEffect);
}
}
}

// The following switch statement is only concerned about placement,
Expand Down Expand Up @@ -2287,8 +2296,16 @@ function commitLayoutEffects(root: FiberRoot, committedLanes: Lanes) {
commitLayoutEffectOnFiber(root, current, nextEffect, committedLanes);
}

if (effectTag & Ref) {
commitAttachRef(nextEffect);
if (enableScopeAPI) {
// TODO: This is a temporary solution that allows us to transition away
// from React Flare on www.
if (effectTag & Ref && nextEffect.tag !== ScopeComponent) {
commitAttachRef(nextEffect);
}
} else {
if (effectTag & Ref) {
commitAttachRef(nextEffect);
}
}

resetCurrentDebugFiberInDEV();
Expand Down
21 changes: 19 additions & 2 deletions packages/react-reconciler/src/ReactFiberWorkLoop.old.js
Expand Up @@ -29,6 +29,7 @@ import {
decoupleUpdatePriorityFromScheduler,
enableDebugTracing,
enableSchedulingProfiler,
enableScopeAPI,
} from 'shared/ReactFeatureFlags';
import ReactSharedInternals from 'shared/ReactSharedInternals';
import invariant from 'shared/invariant';
Expand Down Expand Up @@ -111,6 +112,7 @@ import {
Block,
OffscreenComponent,
LegacyHiddenComponent,
ScopeComponent,
} from './ReactWorkTags';
import {LegacyRoot} from './ReactRootTags';
import {
Expand Down Expand Up @@ -2324,6 +2326,13 @@ function commitMutationEffects(root: FiberRoot, renderPriorityLevel) {
if (current !== null) {
commitDetachRef(current);
}
if (enableScopeAPI) {
// TODO: This is a temporary solution that allows us to transition away
// from React Flare on www.
if (nextEffect.tag === ScopeComponent) {
commitAttachRef(nextEffect);
}
}
}

// The following switch statement is only concerned about placement,
Expand Down Expand Up @@ -2404,8 +2413,16 @@ function commitLayoutEffects(root: FiberRoot, committedLanes: Lanes) {
commitLayoutEffectOnFiber(root, current, nextEffect, committedLanes);
}

if (effectTag & Ref) {
commitAttachRef(nextEffect);
if (enableScopeAPI) {
// TODO: This is a temporary solution that allows us to transition away
// from React Flare on www.
if (effectTag & Ref && nextEffect.tag !== ScopeComponent) {
commitAttachRef(nextEffect);
}
} else {
if (effectTag & Ref) {
commitAttachRef(nextEffect);
}
}

resetCurrentDebugFiberInDEV();
Expand Down