dillon1000/react

Commit

Don't call onCommit et al if there are no effects (#19863)

* Don't call onCommit et al if there are no effects

Checks `subtreeFlags` before scheduling an effect on the Profiler.

* Fix failing Profiler tests

The change to conditionally call Profiler commit hooks only if updates were scheduled broke a few of the Profiler tests. I've fixed the tests by either:
* Adding a no-op passive effect into the subtree or
* Converting onPostCommit to onCommit

When possible, I opted to add the no-op passive effect to the tests since that that hook is called later (during passive phase) so the test is a little broader. In a few cases, this required adding awkward act() wrappers so I opted to go with onCommit instead.

Co-authored-by: Brian Vaughn <[email protected]>
Browse files
Changed paths4 files
First-parent comparison
M packages/react-reconciler/src/ReactFiberBeginWork.new.js ModifiedM packages/react-reconciler/src/ReactFiberCommitWork.new.js ModifiedM packages/react-reconciler/src/ReactFiberCompleteWork.new.js ModifiedM packages/react/src/__tests__/ReactProfiler-test.internal.js Modified
Patch

Files changed

Rendering syntax-highlighted changes…