Repository navigation
Flush pending effects before a queued rerender - #5296
Draft
JoviDeCroock wants to merge 4 commits into
Draft
JoviDeCroock wants to merge 4 commits into
JoviDeCroock wants to merge 4 commits into
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: +59 B (+0.37%) Total Size: 16 kB 📦 View Changed
ℹ️ View Unchanged
|
A render that throws now leaves the rest of the queue scheduled, so teardown() can render a second throwing component. Restore debounceRendering in a finally and catch the error in act(), keeping the first one, so actDepth and requestAnimationFrame are always reset.
This branch has not been deployed
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.
Fixes #3666
A rerender that is queued before the previous commit's
useEffects have run now runs them first, as React does. Radix registers Slider thumbs in an effect and reads them in the rerender that a ref callback queues, so before this change the thumbs never got an index and stayed hidden.Builds on #5265 (its two commits are included here): an effect error now throws out of the flush before anything renders, and the queue is rescheduled instead of dropped, so neither the effect error nor a later render error is lost.
The flush happens in core, through a private
options._flushEffectshook thatprocess()calls before draining the queue. #5163 tried to get the same behaviour by wrappingoptions.debounceRenderingfrompreact/hooks, which had these problems:setupRerender()/actreplaced the wrapper, so tests ran with different effect timing than apps, and test-utils needed patches.Here
process()runs on every path, including custom schedulers andact. Only effects of finished commits that kept their tree are flushed early:flushSyncin a ref or layout effect, a syncdebounceRendering) still runs layout effects first.lazy()don't mount and unmount their effects.flushSync, doesn't run twice.Cost: core +6 B (including #5265) and hooks +36 B brotli.
Verified with
@radix-ui/react-slider@1.4.5: on 11.0.0 both thumbs sit at 0% with noaria-valuenow; with this branch they render at 25% and 75% and keyboard changes move them.Note
Verified by GPT6.1-sol