Skip to content

v1.0.17

Latest

Choose a tag to compare

@debabin debabin released this 01 Sep 13:01
· 8 commits to main since this release

Fix edge cases

This release fixes two timing bugs and raises unit and mutation test coverage for useTimer, useThrottleCallback and useThrottleEffect.

Fixes

  • useTimer — the timer no longer goes negative when crossing zero. The stop condition was a strict updatedSeconds === 0, so a fractional seconds count (e.g. useTimer(2.5) or restart(0.4)) never landed exactly on 0: active stayed true and count ran negative indefinitely. It now stops on updatedSeconds <= 0 with a clamp to 0, matching the existing pattern in decrease().
  • useThrottleCallback — a call arriving right after a trailing invocation no longer bypasses the throttle window. isCalledRef was reset unconditionally on every timer tick, so the next call saw isCalledRef === false and fired immediately instead of queuing, breaking the once-per-delay guarantee. The reset now happens only when there are no pending trailing calls, matching utils/helpers/throttle.ts. useThrottleState and useThrottleValue inherit the fix since both wrap useThrottleCallback.

Changes