Appearance
useIntervalFn
Wrapper for setInterval with controls
Demo
Usage
tsx
import { useIntervalFn } from '@reause/shared'
const { isActive, pause, resume } = useIntervalFn(() => {
/* ... */
}, 1000)Type Declarations
ts
export interface UseIntervalFnOptions {
immediate?: boolean;
immediateCallback?: boolean;
}
export interface UseIntervalFnReturn {
isActive: boolean;
pause: () => void;
resume: () => void;
}
type Fn = () => void
export function useIntervalFn(cb: Fn, interval?: number, options?: UseIntervalFnOptions): UseIntervalFnReturn