📜  清除 setInterval - Javascript 代码示例

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

代码示例2
const App = () => {
  const [loading, setLoading] = React.useState(true);
  React.useEffect(() => {
    const interval = setInterval(() => {
      setLoading(false);
    }, 3000);
    return () => clearInterval(interval);
  }, []);
  return (
    
{loading ?

Loading

:

Counter

}
); } ReactDOM.render(, document.getElementById("root"));