-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[@mantine.core] Transition clear all timers and RAF on rapid state ch… #7773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[@mantine.core] Transition clear all timers and RAF on rapid state ch… #7773
Conversation
1b3f66f
to
8f8f14b
Compare
I think this may be related to an issue I found today... We are rendering a button in a table and when scrolling wildly vertical/horizontally in the table we get a crash with "Maxium update depth exceeded". I traced it into the Mantine button and specifically to the line Transition is rendered. We are using AG Grid which I believe will do performant rendering of the rows, i.e. it will mount/unmount the buttons regularly while scrolling to keep only the visible content mounted. Possibly rapid mount/unmount of ~70 buttons causes Transition to misbehave like this? |
Note: This Patch May Help Prevent Maximum Update Depth Error in TransitionsThis patch could help mitigate the "Maximum update depth exceeded" error What’s the Issue?
How This Commit May Help
Potential Impact and Limitations
ConclusionThis patch may provide a practical way to reduce infinite render loop risks |
Please remove last commit, this PR must point to v7 branch, it should not merge master changes in |
fc87051
to
8f8f14b
Compare
…anges to prevent animation glitches - Add clearAllTimeouts to clear transitionTimeoutRef, delayTimeoutRef, and rafRef - Ensure all timers and RAF are cleared before starting a new transition or delay - Prevents animation glitches and state corruption when toggling rapidly
8f8f14b
to
b07caa5
Compare
Thanks! |
Fix: Prevent animation glitches on rapid state changes in Transition
What
This PR ensures that all timers (
transitionTimeoutRef
,delayTimeoutRef
) and animation frames (rafRef
) are cleared before starting a new transition or delay in the useTransition hook.Why
Previously, only
transitionTimeoutRef
was cleared when a new transition started. However, when rapidly toggling the transition state, other timers and RAF callbacks (such asdelayTimeoutRef
andrafRef
) could still be pending, leading to animation glitches, state corruption, or unexpected behavior.How
Impact
fix: #6381