@@ -66,7 +66,7 @@ if (__DEV__) {
6666 return self;
6767 }
6868
69- var ReactVersion = "18.3.0-www-classic-fc548c7d ";
69+ var ReactVersion = "18.3.0-www-classic-162b9b5d ";
7070
7171 var LegacyRoot = 0;
7272 var ConcurrentRoot = 1;
@@ -187,7 +187,8 @@ if (__DEV__) {
187187 dynamicFeatureFlags.transitionLaneExpirationMs,
188188 enableInfiniteRenderLoopDetection =
189189 dynamicFeatureFlags.enableInfiniteRenderLoopDetection,
190- enableRenderableContext = dynamicFeatureFlags.enableRenderableContext; // On WWW, false is used for a new modern build.
190+ enableRenderableContext = dynamicFeatureFlags.enableRenderableContext,
191+ useModernStrictMode = dynamicFeatureFlags.useModernStrictMode; // On WWW, false is used for a new modern build.
191192 var enableProfilerTimer = true;
192193 var enableProfilerCommitHooks = true;
193194 var enableProfilerNestedUpdatePhase = true;
@@ -28106,9 +28107,121 @@ if (__DEV__) {
2810628107 }
2810728108 }
2810828109
28110+ function recursivelyTraverseAndDoubleInvokeEffectsInDEV(
28111+ root,
28112+ parentFiber,
28113+ isInStrictMode
28114+ ) {
28115+ if (
28116+ (parentFiber.subtreeFlags & (PlacementDEV | Visibility)) ===
28117+ NoFlags$1
28118+ ) {
28119+ // Parent's descendants have already had effects double invoked.
28120+ // Early exit to avoid unnecessary tree traversal.
28121+ return;
28122+ }
28123+
28124+ var child = parentFiber.child;
28125+
28126+ while (child !== null) {
28127+ doubleInvokeEffectsInDEVIfNecessary(root, child, isInStrictMode);
28128+ child = child.sibling;
28129+ }
28130+ } // Unconditionally disconnects and connects passive and layout effects.
28131+
28132+ function doubleInvokeEffectsOnFiber(root, fiber) {
28133+ var shouldDoubleInvokePassiveEffects =
28134+ arguments.length > 2 && arguments[2] !== undefined
28135+ ? arguments[2]
28136+ : true;
28137+ disappearLayoutEffects(fiber);
28138+
28139+ if (shouldDoubleInvokePassiveEffects) {
28140+ disconnectPassiveEffect(fiber);
28141+ }
28142+
28143+ reappearLayoutEffects(root, fiber.alternate, fiber, false);
28144+
28145+ if (shouldDoubleInvokePassiveEffects) {
28146+ reconnectPassiveEffects(root, fiber, NoLanes, null, false);
28147+ }
28148+ }
28149+
28150+ function doubleInvokeEffectsInDEVIfNecessary(
28151+ root,
28152+ fiber,
28153+ parentIsInStrictMode
28154+ ) {
28155+ var isStrictModeFiber = fiber.type === REACT_STRICT_MODE_TYPE;
28156+ var isInStrictMode = parentIsInStrictMode || isStrictModeFiber; // First case: the fiber **is not** of type OffscreenComponent. No
28157+ // special rules apply to double invoking effects.
28158+
28159+ if (fiber.tag !== OffscreenComponent) {
28160+ if (fiber.flags & PlacementDEV) {
28161+ setCurrentFiber(fiber);
28162+
28163+ if (isInStrictMode) {
28164+ doubleInvokeEffectsOnFiber(
28165+ root,
28166+ fiber,
28167+ (fiber.mode & NoStrictPassiveEffectsMode) === NoMode
28168+ );
28169+ }
28170+
28171+ resetCurrentFiber();
28172+ } else {
28173+ recursivelyTraverseAndDoubleInvokeEffectsInDEV(
28174+ root,
28175+ fiber,
28176+ isInStrictMode
28177+ );
28178+ }
28179+
28180+ return;
28181+ } // Second case: the fiber **is** of type OffscreenComponent.
28182+ // This branch contains cases specific to Offscreen.
28183+
28184+ if (fiber.memoizedState === null) {
28185+ // Only consider Offscreen that is visible.
28186+ // TODO (Offscreen) Handle manual mode.
28187+ setCurrentFiber(fiber);
28188+
28189+ if (isInStrictMode && fiber.flags & Visibility) {
28190+ // Double invoke effects on Offscreen's subtree only
28191+ // if it is visible and its visibility has changed.
28192+ doubleInvokeEffectsOnFiber(root, fiber);
28193+ } else if (fiber.subtreeFlags & PlacementDEV) {
28194+ // Something in the subtree could have been suspended.
28195+ // We need to continue traversal and find newly inserted fibers.
28196+ recursivelyTraverseAndDoubleInvokeEffectsInDEV(
28197+ root,
28198+ fiber,
28199+ isInStrictMode
28200+ );
28201+ }
28202+
28203+ resetCurrentFiber();
28204+ }
28205+ }
28206+
2810928207 function commitDoubleInvokeEffectsInDEV(root, hasPassiveEffects) {
2811028208 {
28111- {
28209+ if (useModernStrictMode && root.tag !== LegacyRoot) {
28210+ var doubleInvokeEffects = true;
28211+
28212+ if (
28213+ root.tag === ConcurrentRoot &&
28214+ !(root.current.mode & (StrictLegacyMode | StrictEffectsMode))
28215+ ) {
28216+ doubleInvokeEffects = false;
28217+ }
28218+
28219+ recursivelyTraverseAndDoubleInvokeEffectsInDEV(
28220+ root,
28221+ root.current,
28222+ doubleInvokeEffects
28223+ );
28224+ } else {
2811228225 legacyCommitDoubleInvokeEffectsInDEV(root.current, hasPassiveEffects);
2811328226 }
2811428227 }
0 commit comments