Horje
clearinterval in useEffect Code Example
clearinterval in useEffect
let intervalID;
useEffect(() => {
    if (isRunning) {
      intervalID = setInterval(() => {
        dispatch({ type: "tic-toc" });
      }, 1000);
    }
      return () => clearInterval(intervalID);
  }, [isRunning]);
useeffect clearinterval loading
const Loading = () => {
  const [loadingStatus, setLoadingStatus] = useState(".");

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

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

  return <p>{`Loading ${loadingStatus}`}</p>;
};




Javascript

Related
jquery if null or empty Code Example jquery if null or empty Code Example
automatically scroll to bottom of page Code Example automatically scroll to bottom of page Code Example
js scroll to bottom Code Example js scroll to bottom Code Example
jquery change font size Code Example jquery change font size Code Example
Javascript how to run hello world Code Example Javascript how to run hello world Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8