useInterval
Interval 使用hooks,提供 useEffect 自动绑定解绑方式 和 手动绑定方式
安装
npm
pnpm
yarn
npm install @jelper/hooks
引入
import { useInterval } from '@jelper/hooks';
样例
基础用法
count: 0
基础用法
API
参数 | 说明 | 类型 | 默认值 | 版本 |
---|---|---|---|---|
useInterval | 使用 useEffect 封装 interval | UseInterval | -- | |
useIntervalHandler | 使用 interval 句柄 | UseIntervalHandler | -- |
Interface
type UseInterval = (callback: Function, timeout?: number, ...arg: any[]) => (() => void);
type UseIntervalHandler = () => [
(callback: Function, timeout?: number, ...arg: any[]) => void, // 绑定事件
() => void, // 清除事件
];