hooks-belt
Version:
A comprehensive collection of useful React hooks for common use cases
29 lines • 794 B
TypeScript
/**
* A hook that provides a way to run a function at regular intervals.
* Automatically handles cleanup and can be paused/resumed.
*
* @param callback - The function to call on each interval
* @param delay - The delay between calls in milliseconds (null to pause)
*
* @example
* ```tsx
* const [count, setCount] = useState(0)
* const [isRunning, setIsRunning] = useState(true)
*
* useInterval(
* () => setCount(c => c + 1),
* isRunning ? 1000 : null
* )
*
* return (
* <div>
* Count: {count}
* <button onClick={() => setIsRunning(!isRunning)}>
* {isRunning ? 'Pause' : 'Resume'}
* </button>
* </div>
* )
* ```
*/
export declare function useInterval(callback: () => void, delay: number | null): void;
//# sourceMappingURL=useInterval.d.ts.map