useExpiry
useExpiry(
target,onExpire):void
Defined in: useExpiry.ts:20
Fire onExpire exactly once when wall-clock time reaches target. A
single setTimeout per call; re-arms when target changes; cleans up
on unmount.
Pass null to disarm. If the target is already past at mount time,
fires the callback synchronously inside the effect.
This is the “one-shot” companion to useCountdown (which ticks every
second for display). Use both together when you need both a visible
countdown and a state mutation at zero.
The callback can change between renders without re-arming the
timeout — internally it’s stashed in a ref. That way callers can
pass an inline closure (() => dispatch(...)) without thrashing the
timer.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
target | number | null |
onExpire | () => void |
Returns
Section titled “Returns”void