useInterval

在指定的时间间隔执行给定的回调函数。


import { useInterval } from 'primereact/hooks';
         

每秒更新的简单计时器。

0

useInterval(
    () => {
        setSeconds((prevSecond) => (prevSecond === 59 ? 0 : prevSecond + 1)); //fn
    },
    1000,   //delay (ms)
    active  //condition (when)
);