title: ReactJS useEffect dependency warning leads to infninite loop
body: <p>In my functional component i have state and whenever it changes i want to do some stuff. So i used useEffect, but it gives &quot;dependency missing&quot; error. After i put all the dependencies shown in the error i get infinite loop. Here is the code:</p>
  <pre><code>const [keywords, setKeywords] = useState&lt;Keyword[]&gt;();
  const [currentPage, pagingConfig, setPagingConfig] = usePaging();
  
    useEffect(() =&gt; {
      const loadKeywords = async () =&gt; {
        const { current, pageSize } = pagingConfig;
        const keywords = await getKeywords(current as number, pageSize as number);
        setKeywords(keywords.data.data);
        setPagingConfig({
          ...pagingConfig,
          total: keywords.data.total,
        });
      };
      loadKeywords();
    }, [currentPage]); // Requires to add pagingConfig and setPagingConfig
  </code></pre>
  <p>If required dependencies are added i get infinite loop.</p>
  <p>How can i avoid this error?</p>