title: Is there a correct way to use an object as a dependency in useEffect?
body: <p>I currently have a react hook that I'm creating that accepts a query object.</p>
  
  <pre class="lang-js prettyprint-override"><code>export function useMyQuery(query: QueryObjectType)
  {
      React.useEffect(executeQuery, [ query ]);
      // ...
  }
  </code></pre>
  
  <p>Unfortunately, any time my hook gets called as part of a re-render, despite <code>query</code> having never changed and still being the exact same object as before, I end up with an infinite loop.</p>
  
  <p>I can resolve this by wrapping <code>query</code> with <code>JSON.stringify(...)</code>, however I'm not sure if that's correct? Is there any preferred mechanism for testing equality for objects when being passed as a dependency to <code>useEffect</code>?</p>