Skip to content

Commit

Permalink
Fix: Infinite act loop caused by wrong shouldYield
Browse files Browse the repository at this point in the history
Fixes the bug demonstrated by the regression test in the previous
commit. Refer to previous message for details.
  • Loading branch information
acdlite committed Mar 5, 2023
1 parent d852892 commit fe7719c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/react-reconciler/src/ReactFiberWorkLoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -2268,7 +2268,17 @@ function renderRootConcurrent(root: FiberRoot, lanes: Lanes) {
}
}
}
workLoopConcurrent();

if (__DEV__ && ReactCurrentActQueue.current !== null) {
// `act` special case: If we're inside an `act` scope, don't consult
// `shouldYield`. Always keep working until the render is complete.
// This is not just an optimization: in a unit test environment, we
// can't trust the result of `shouldYield`, because the host I/O is
// likely mocked.
workLoopSync();
} else {
workLoopConcurrent();
}
break;
} catch (thrownValue) {
handleThrow(root, thrownValue);
Expand Down

0 comments on commit fe7719c

Please sign in to comment.