@@ -135,10 +135,14 @@ export function useAnimatedCount(targetValue, elementRef, skipAnimation = false)
135135 // Update visibility tracking
136136 wasVisibleRef . current = isCurrentlyVisible ;
137137
138+ // Read skipAnimation value directly from signal if it's a signal, otherwise use state
139+ // This ensures we get the latest value synchronously, avoiding race conditions
140+ const currentSkipAnimation = isSignal ? skipAnimation . value : shouldSkipAnimation ;
141+
138142 if ( isCurrentlyVisible ) {
139143 // If skipAnimation is true (e.g., after burn all), immediately set to target value
140144 // This skips the countdown animation and goes directly to empty state (when targetValue is 0)
141- if ( shouldSkipAnimation ) {
145+ if ( currentSkipAnimation ) {
142146 // Cancel any ongoing animation immediately
143147 cancelAnimation ( ) ;
144148 // Immediately set to target value without animation
@@ -193,9 +197,12 @@ export function useAnimatedCount(targetValue, elementRef, skipAnimation = false)
193197 wasVisibleRef . current = isNowVisible ;
194198
195199 if ( isNowVisible ) {
200+ // Read skipAnimation value directly from signal if it's a signal, otherwise use state
201+ const currentSkipAnimation = isSignal ? skipAnimation . value : shouldSkipAnimation ;
202+
196203 // If skipAnimation is true (e.g., after burn all), immediately set to target value
197204 // This skips the countdown animation and goes directly to empty state (when targetValue is 0)
198- if ( shouldSkipAnimation ) {
205+ if ( currentSkipAnimation ) {
199206 cancelAnimation ( ) ;
200207 // Immediately set to target value without animation
201208 // When targetValue is 0, this will trigger the empty state display
0 commit comments