title: React setInterval in useEffect with setTimeout delay
body: <p>I want to run an interval with a delay for the first time it fires. How can I do this with useEffect? Because of the syntax I've found it difficult to achieve what I want to do</p>
  
  <p>The interval function</p>
  
  <pre><code>  useEffect(()=&gt;{
      const timer = setInterval(() =&gt; {
        //do something here
        return ()=&gt; clearInterval(timer)
      }, 1000);
    },[/*dependency*/])
  </code></pre>
  
  <p>The delay function</p>
  
  <pre><code>useEffect(() =&gt; {
      setTimeout(() =&gt; {
  //I want to run the interval here, but it will only run once 
  //because of no dependencies. If i populate the dependencies, 
  //setTimeout will run more than once.
  }, Math.random() * 1000);
    }, []);
  </code></pre>
  
  <p>Sure it is achievable somehow...</p>