title: React maximum update depth exceeded | useEffect dependencies
body: <p>I have a certain piece of code that I want to run when any of the dependencies change. One of those dependencies is not being used inside the effect</p>
  <pre><code>  const { contractParams, serviceInstance } = entityStore;
    useEffect(() =&gt; {
          const [first, second, third, fourth] = getParamDetails(contractParams);
          setFirst(first);
          setSecond(second);
          setThird(third);
          setFourth(fourth);
      }, [contractParams, serviceInstance]);
  </code></pre>
  <p>I want to run this code or trigger a re-render when any of them changes. However, i understand since I am not referring  <code>serviceInstance</code> inside this useEffect, its not exactly a dependency per se. However, when I run it, I get this error</p>
  <pre><code>Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn't have a dependency array, or one of the dependencies changes on every render.
  </code></pre>
  <p>If I remove serviceInstance, it goes away.Both of the dependencies are array. Is it treating serviceInstance a diff value on every update? What am I missing? Any suggestions are appreciated</p>