use-interval
Wrapper around window.setInterval
Usage
Page loaded 0 seconds ago
API
const { start, stop, toggle, active } = useInterval(fn, interval);Arguments:
fn– function that will be called at each interval tickinterval– amount of milliseconds between each tick
Return object:
start– start intervalstop– stop intervaltoggle– toggle intervalactive– current interval status
Definition
function useInterval(
fn: () => void,
interval: number
): {
start: () => void;
stop: () => void;
toggle: () => void;
active: boolean;
};