dillon1000/react

Commit

Fix: flushSync changes priority inside effect (#21122)

When called from inside an effect, flushSync cannot synchronously flush
its updates because React is already working. So we fire a warning.

However, we should still change the priority of the updates to sync so
that they flush at the end of the current task.

This only affects useEffect because updates inside useLayoutEffect (and
the rest of the commit phase, like ref callbacks) are already sync.
Browse files
Changed paths3 files
First-parent comparison
M packages/react-reconciler/src/ReactFiberWorkLoop.new.js ModifiedM packages/react-reconciler/src/ReactFiberWorkLoop.old.js ModifiedA packages/react-reconciler/src/__tests__/ReactFlushSync-test.js Added
Patch

Files changed

Rendering syntax-highlighted changes…