Commit pending hook state in options._render - #5187
Merged
Merged
Conversation
📊 Tachometer Benchmark ResultsSummaryduration
usedJSHeapSize
Resultscreate10kduration
usedJSHeapSize
filter-listduration
usedJSHeapSize
hydrate1kduration
usedJSHeapSize
many-updatesduration
usedJSHeapSize
replace1kduration
usedJSHeapSize
run-warmup-0
run-warmup-1
run-warmup-2
run-warmup-3
run-warmup-4
run-final
text-updateduration
usedJSHeapSize
tododuration
usedJSHeapSize
update10th1kduration
usedJSHeapSize
|
|
Size Change: -56 B (-0.35%) Total Size: 15.8 kB 📦 View Changed
ℹ️ View Unchanged
|
`useReducer` installed two closures on every hook-using component: a `shouldComponentUpdate` that both decided the bail-out and committed `_nextValue` -> `_value`, and a `componentWillUpdate` that existed only to run that same commit on the forced-update path, where core skips sCU. It did so by temporarily nulling `prevScu` and re-entering the sCU, smuggling a mutation through a predicate. The commit belongs in neither. `options._render` runs immediately before every render, forced or not, and already ran this exact loop for the same-component re-render branch. Hoisting it out unconditionally makes `componentWillUpdate` unnecessary and leaves sCU a pure predicate. Clearing `_pendingArgs` unconditionally is safe because `options.diffed` promotes them after every successful diff, so leftovers belong to a render that never committed and this render recomputes them. On bail-out `_nextValue` simply stays pending; the dispatcher already reads `_nextValue[0]` when present. hooks: 1387 -> 1331 B brotli (-4.0%). Also drops a closure per component instance, and stops compat's UNSAFE_* accessor setter from running `Object.defineProperty` on every hook component. The forced-update path had no coverage, so add a test that drives it through a context provider.
JoviDeCroock
force-pushed
the
golf-hooks-bytes
branch
from
July 31, 2026 07:09
3d58db8 to
d18a874
Compare
Assigning `componentWillUpdate` on an instance was only ever exercised by `useReducer` installing its own; with that gone the setter half of the `UNSAFE_*` alias accessors has no caller in the suite. It is still a supported path for user code, so test it on its own.
marvinhagemeister
approved these changes
Jul 31, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
useReducerinstalled two closures on every hook-using component: ashouldComponentUpdatethat both decided the bail-out and committed_nextValue->_value, and acomponentWillUpdatethat existed only to run that same commit on the forced-update path, where core skips sCU. It did so by temporarily nullingprevScuand re-entering the sCU, smuggling a mutation through a predicate.The commit belongs in neither.
options._renderruns immediately before every render, forced or not, and already ran this exact loop for the same-component re-render branch. Hoisting it out unconditionally makescomponentWillUpdateunnecessary and leaves sCU a pure predicate.Clearing
_pendingArgsunconditionally is safe becauseoptions.diffedpromotes them after every successful diff, so leftovers belong to a render that never committed and this render recomputes them. On bail-out_nextValuesimply stays pending; the dispatcher already reads_nextValue[0]when present.