Skip to content

Commit fb31042

Browse files
committed
Fix: Infinite act loop caused by wrong shouldYield
Fixes the bug demonstrated by the regression test in the previous commit. Refer to previous message for details.
1 parent 1a00e1f commit fb31042

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/react-reconciler/src/ReactFiberWorkLoop.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2268,7 +2268,17 @@ function renderRootConcurrent(root: FiberRoot, lanes: Lanes) {
22682268
}
22692269
}
22702270
}
2271-
workLoopConcurrent();
2271+
2272+
if (__DEV__ && ReactCurrentActQueue.current !== null) {
2273+
// `act` special case: If we're inside an `act` scope, don't consult
2274+
// `shouldYield`. Always keep working until the render is complete.
2275+
// This is not just an optimization: in a unit test environment, we
2276+
// can't trust the result of `shouldYield`, because the host I/O is
2277+
// likely mocked.
2278+
workLoopSync();
2279+
} else {
2280+
workLoopConcurrent();
2281+
}
22722282
break;
22732283
} catch (thrownValue) {
22742284
handleThrow(root, thrownValue);

0 commit comments

Comments
 (0)