Skip to content

Commit

Permalink
Add PassiveStatic to trees with passive effects
Browse files Browse the repository at this point in the history
Indicates that a tree needs passive clean-up on deletion.
  • Loading branch information
acdlite committed Dec 18, 2020
1 parent ff17fc1 commit 19e15a3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/react-reconciler/src/ReactFiberHooks.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import {readContext} from './ReactFiberNewContext.new';
import {
Update as UpdateEffect,
Passive as PassiveEffect,
PassiveStatic as PassiveStaticEffect,
} from './ReactFiberFlags';
import {
HasEffect as HookHasEffect,
Expand Down Expand Up @@ -1304,7 +1305,7 @@ function mountEffect(
}
}
return mountEffectImpl(
UpdateEffect | PassiveEffect,
UpdateEffect | PassiveEffect | PassiveStaticEffect,
HookPassive,
create,
deps,
Expand Down
3 changes: 2 additions & 1 deletion packages/react-reconciler/src/ReactFiberHooks.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import {readContext} from './ReactFiberNewContext.old';
import {
Update as UpdateEffect,
Passive as PassiveEffect,
PassiveStatic as PassiveStaticEffect,
} from './ReactFiberFlags';
import {
HasEffect as HookHasEffect,
Expand Down Expand Up @@ -1304,7 +1305,7 @@ function mountEffect(
}
}
return mountEffectImpl(
UpdateEffect | PassiveEffect,
UpdateEffect | PassiveEffect | PassiveStaticEffect,
HookPassive,
create,
deps,
Expand Down
3 changes: 2 additions & 1 deletion packages/react-reconciler/src/ReactFiberWorkLoop.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ import {
HostEffectMask,
Hydrating,
HydratingAndUpdate,
StaticMask,
} from './ReactFiberFlags';
import {
NoLanePriority,
Expand Down Expand Up @@ -1781,7 +1782,7 @@ function completeUnitOfWork(unitOfWork: Fiber): void {
// Skip both NoWork and PerformedWork tags when creating the effect
// list. PerformedWork effect is read by React DevTools but shouldn't be
// committed.
if (flags > PerformedWork) {
if ((flags & ~StaticMask) > PerformedWork) {
if (returnFiber.lastEffect !== null) {
returnFiber.lastEffect.nextEffect = completedWork;
} else {
Expand Down
3 changes: 2 additions & 1 deletion packages/react-reconciler/src/ReactFiberWorkLoop.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ import {
HostEffectMask,
Hydrating,
HydratingAndUpdate,
StaticMask,
} from './ReactFiberFlags';
import {
NoLanePriority,
Expand Down Expand Up @@ -1781,7 +1782,7 @@ function completeUnitOfWork(unitOfWork: Fiber): void {
// Skip both NoWork and PerformedWork tags when creating the effect
// list. PerformedWork effect is read by React DevTools but shouldn't be
// committed.
if (flags > PerformedWork) {
if ((flags & ~StaticMask) > PerformedWork) {
if (returnFiber.lastEffect !== null) {
returnFiber.lastEffect.nextEffect = completedWork;
} else {
Expand Down

0 comments on commit 19e15a3

Please sign in to comment.