📌  相关文章
📜  useEffect 中的 clearinterval - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:29.600000             🧑  作者: Mango

代码示例2
const Loading = () => {
  const [loadingStatus, setLoadingStatus] = useState(".");

  useEffect(() => {
    const intervalId = setInterval(() => {
      setLoadingStatus(ls => ls + ".");
    }, 1000);

    return () => clearInterval(intervalId);
  }, []);

  return 

{`Loading ${loadingStatus}`}

; };