Q:

useeffect with cleanup

  useEffect(() => {
	//your code goes here
    return () => {
      //your cleanup code codes here
    };
  },[]);
1
  useEffect(() => {
	
  },[]);
1
function App() {
  const [shouldRender, setShouldRender] = useState(true);

  useEffect(() => {
    setTimeout(() => {
      setShouldRender(false);
    }, 5000);
  }, []);

  // don't render
  if( !shouldRender ) return null;
  // JSX, if the shouldRender is true
  return <ForExample />;
}
0

New to Communities?

Join the community