title: React Hooks: useEffect with dependecy also called when component mounts
body: <p>In React, you can use <em>useEffect()</em> hook with a dependency on it.</p>
  <pre><code>const [data, setData] = useState();
  
  useEffect(() =&gt; {
      console.log(data.test.test);
  }, [data]);
  </code></pre>
  <p>So I would assume that this <em>useEffect</em> is just called when the data is changed.
  So let´s assume I would make an api call and use <em>setData(response.data)</em>.</p>
  <p>Then the <em>useEffect()</em> should be triggerd, since the <em>data</em> state is a dependecy.</p>
  <p>Then the <em>console.log(data.tes.test)</em> would be working, since I got the right data.
  However, I get an <em>undefined</em> error, which comes from the fact that useEffect() is also called initially.</p>
  <p>How can I avoid this? This is pretty annoying and in my mind not a good design with regard to adding a dependency.</p>