title: useEffect second argument variations in React hook?
body: <p>In react hooks, what is the difference between these 3 snippets.</p>
  
  <pre><code>//1.
  
  function App() {
    const [isOn, setIsOn] = useState(false);
  
    useEffect(() =&gt; {
      const interval = setInterval(() =&gt; console.log('tick'), 1000);
  
      return () =&gt; clearInterval(interval);
    });
  }
  
  //2.
  
  function App() {
    const [isOn, setIsOn] = useState(false);
  
    useEffect(() =&gt; {
      const interval = setInterval(() =&gt; console.log('tick'), 1000);
  
      return () =&gt; clearInterval(interval);
    }, []);
  }
  
  //3. 
  
  function App() {
    const [isOn, setIsOn] = useState(false);
  
    useEffect(() =&gt; {
      const interval = setInterval(() =&gt; console.log('tick'), 1000);
  
      return () =&gt; clearInterval(interval);
    }, [isOn]);
  }
  </code></pre>
  
  <p>Difference between passing empty array, array with an element and not passing at all? </p>