diff --git a/packages/react-reconciler/src/ReactFiberRootScheduler.js b/packages/react-reconciler/src/ReactFiberRootScheduler.js index faff2cc954..99624f918f 100644 --- a/packages/react-reconciler/src/ReactFiberRootScheduler.js +++ b/packages/react-reconciler/src/ReactFiberRootScheduler.js @@ -23,6 +23,8 @@ import { markRootEntangled, mergeLanes, claimNextTransitionLane, + includesSomeLane, + UpdateLanes, } from './ReactFiberLane'; import { CommitContext, @@ -232,6 +234,10 @@ function flushSyncWorkAcrossRoots_impl(onlyLegacy: boolean) { root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes, ); if (includesSyncLane(nextLanes)) { + // Avoid triggering the warning on selective hydartion + if (!includesSomeLane(nextLanes, UpdateLanes)) { + nestedUpdatePasses = 0; + } // This root has pending sync work. Flush it now. try { didPerformSomeWork = true; diff --git a/packages/react-reconciler/src/ReactFiberWorkLoop.js b/packages/react-reconciler/src/ReactFiberWorkLoop.js index d7a99b1af3..4fcff07cf3 100644 --- a/packages/react-reconciler/src/ReactFiberWorkLoop.js +++ b/packages/react-reconciler/src/ReactFiberWorkLoop.js @@ -3010,9 +3010,9 @@ function commitRootImpl( // those scenarios otherwise. This won't catch recursive async updates, // though, which is why we check the flags above first. // Was the finished render the result of an update (not hydration)? - includesSomeLane(lanes, UpdateLanes) && - // Did it schedule a sync update? - includesSomeLane(remainingLanes, SyncUpdateLanes) + (includesSomeLane(lanes, UpdateLanes) && + // Did it schedule a sync update? + includesSomeLane(remainingLanes, SyncUpdateLanes)) ) { if (enableProfilerTimer && enableProfilerNestedUpdatePhase) { markNestedUpdateScheduled();