We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 37c68f8 commit 02c7fb1Copy full SHA for 02c7fb1
1 file changed
packages/react-hooks/src/useAsyncInterval.ts
@@ -57,10 +57,8 @@ export function useAsyncInterval(
57
58
elapsedSinceLastTick += Date.now() - trackingStartedRef.current;
59
60
- // Calculate any elapsed time beyond the target interval. Note that
61
- // elapsedSinceLastTick should always be >= targetIntervalMs, so overage
62
- // should always be >= 0.
63
- const overage = elapsedSinceLastTick - targetIntervalMs;
+ // Calculate any elapsed time beyond the target interval.
+ const overage = Math.max(0, elapsedSinceLastTick - targetIntervalMs);
64
65
const nextTickInterval = Math.max(0, targetIntervalMs - overage);
66
0 commit comments