mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Make temporary NoStrictPassiveEffects option work with useModernStrictMode (#27105)
## Summary Since we are enabling `useModernStrictMode` flag internally, to make sure the internal testing of half StrictMode doesn't suddenly break, this PR makes sure it also works with `useModernStrictMode` true. ## Test plan: Manually set `useModernStrictMode` to true. `yarn test ReactOffscreenStrictMode-test -r=www-modern --env=development --variant=true` `yarn test ReactStrictMode-test.internal -r=www-modern --env=development --variant=true`
This commit is contained in:
+17
-4
@@ -90,6 +90,7 @@ import {
|
||||
ConcurrentMode,
|
||||
StrictLegacyMode,
|
||||
StrictEffectsMode,
|
||||
NoStrictPassiveEffectsMode,
|
||||
} from './ReactTypeOfMode';
|
||||
import {
|
||||
HostRoot,
|
||||
@@ -3538,11 +3539,19 @@ function recursivelyTraverseAndDoubleInvokeEffectsInDEV(
|
||||
}
|
||||
|
||||
// Unconditionally disconnects and connects passive and layout effects.
|
||||
function doubleInvokeEffectsOnFiber(root: FiberRoot, fiber: Fiber) {
|
||||
function doubleInvokeEffectsOnFiber(
|
||||
root: FiberRoot,
|
||||
fiber: Fiber,
|
||||
shouldDoubleInvokePassiveEffects: boolean = true,
|
||||
) {
|
||||
disappearLayoutEffects(fiber);
|
||||
disconnectPassiveEffect(fiber);
|
||||
if (shouldDoubleInvokePassiveEffects) {
|
||||
disconnectPassiveEffect(fiber);
|
||||
}
|
||||
reappearLayoutEffects(root, fiber.alternate, fiber, false);
|
||||
reconnectPassiveEffects(root, fiber, NoLanes, null, false);
|
||||
if (shouldDoubleInvokePassiveEffects) {
|
||||
reconnectPassiveEffects(root, fiber, NoLanes, null, false);
|
||||
}
|
||||
}
|
||||
|
||||
function doubleInvokeEffectsInDEVIfNecessary(
|
||||
@@ -3559,7 +3568,11 @@ function doubleInvokeEffectsInDEVIfNecessary(
|
||||
if (fiber.flags & PlacementDEV) {
|
||||
setCurrentDebugFiberInDEV(fiber);
|
||||
if (isInStrictMode) {
|
||||
doubleInvokeEffectsOnFiber(root, fiber);
|
||||
doubleInvokeEffectsOnFiber(
|
||||
root,
|
||||
fiber,
|
||||
(fiber.mode & NoStrictPassiveEffectsMode) === NoMode,
|
||||
);
|
||||
}
|
||||
resetCurrentDebugFiberInDEV();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user