/** * title: 基础使用 * desc: 频繁调用 run,但只会每隔 500ms 执行一次相关函数。 */ import React, { useState } from 'react'; import useThrottleFn from "../../useThrottleFn"; export default () => { const [value, setValue] = useState(0); const { run } = useThrottleFn( () => { setValue(value + 1); }, { wait: 500 }, ); return (
Clicked count: {value}