如何让操作首先运行,以便在页面加载时加载,然后每 4 秒间隔一次?目前,当页面加载时dencrypt等待 4 秒,然后在重复时工作正常
const Home = () => {
const { result, dencrypt } = useDencrypt();
React.useEffect(() => {
let i = 0;
const action = setInterval(() => {
dencrypt(values[i]);
i = i === values.length - 1 ? 0 : i + 1;
}, 4000);
return () => clearInterval(action);
}, []);
守候你守候我
相关分类