title: React Hook useEffect has missing dependencies (witout moving function inside useEffect)
body: <p>This is my part of code. Everything works fine but eslint gives error.</p>
  
  <blockquote>
    <p>React Hook useEffect has missing dependencies: 'dispatch' and 'getData'. Either include them or remove the dependency array  react-hooks/exhaustive-deps</p>
  </blockquote>
  
  <p>I found some solutions but all of say you need to move function inside the useEffect, but I can't. Because I'm calling setData() function sometimes that is in the Jsx.</p>
  
  <p>So getData not only run when component mounted. </p>
  
  <p>Some similar questions but as i said; I can't move function inside the useEffect. Answers always same:</p>
  
  <p><a href="https://stackoverflow.com/questions/56527984/react-hook-useeffect-has-a-missing-dependency">React Hook useEffect has a missing dependency</a></p>
  
  <p><a href="https://stackoverflow.com/questions/55938884/react-hook-useeffect-has-a-missing-dependency-list">React Hook useEffect has a missing dependency: &#39;list&#39;</a></p>
  
  <pre><code>export const Complex = (props) =&gt; {
  // [+] Olmayan başlık tespiti. [+] Var olan başlık tespiti. [-] Daha önce
  // açılmış fakat ilk entrysi silinmiş başlıklar.
  const params = queryString.parse(props.location.search)
  
  let id = props.location.pathname.split("--")[1];
  let str = props.location.pathname.split("--")[0].substr(1);
  
  const data = {
      id: id,
      link: str,
      page: params.sayfa ? parseInt(params.sayfa) : 1,
      isGood: params.guzel ? params.guzel : false
  };
  
  
  // STATE
  const [title,setTitle] = useState("")
  const [titleSubs,setTitleSubs] = useState("")
  const [entryCount,setEntryCount] = useState()
  const [titleId,setTitleID] = useState()
  const [exist,setExist] = useState(true)
  const [entries,setEntries] = useState([])
  const [likes,setLikes] = useState([])
  const [disabled,setDisable] = useState(false)
  const [isLoading,setLoading] = useState(false)
  
  // REDUX
  const titleModal = useSelector(state =&gt; state.settings.titleModal)
  const dataPage = useSelector(state =&gt; state.pageInfo.page)
  const entryNormal = useSelector(state =&gt; state.character.entry.entryNormal)
  const entryCats = useSelector(state =&gt; state.character.entryCats)
  const isAuthenticated = useSelector(state =&gt; state.auth.authenticated)
  const dispatch = useDispatch();
  
  function getData() {
      setLoading(true)
      // For everyone
      axios.post('/api/data/entry/get', data)
      .then(res  =&gt; {
              setExist(true)
              setTitleID(res.data.title.id)
              setEntries(res.data.entries)
              setEntryCount(res.data.count)
              setTitle(res.data.title)
              setTitleSubs(res.data.title.titlesubs)
              setLoading(false)
  
              if (titleModal) {
                  // Send Redux Link Informations
                  dispatch(setCurrentPage({type: null, id: null, title: null}))
              } else {
                  dispatch(setCurrentPage({type: "entry", id: res.data.title.id, title: res.data.title.title}))
              }
      })
      .catch(err =&gt; {
          console.log(err)
          setExist(false)
          setLoading(false)
          setTitle(str)
      })
  
      // If Authenticated.
      // Get liked entries.
      if (isAuthenticated) {
          axios.post('api/data/entry/likes/get', {titleId: data.id})
          .then(res =&gt; {
              const LikesList = [];
              res.data.forEach(data =&gt; {
                  LikesList.push(data.EntryId)
              });
              setLikes(LikesList)
          })
      }
  
  }
  
  useEffect(() =&gt; {
      getData()
      return () =&gt; {
          setEntries([])
          dispatch(setCurrentPage({type: null, id: null, title: null}))
      }
  }, [id, props.location.search])
  
  function getGoodEntriesGeneral() {
      const params = queryString.parse(props.location.search)
      params['guzel'] = true;
      const serialize = obj =&gt; Object.keys(obj)
                           .map(key =&gt; `${key}=${encodeURIComponent(obj[key])}`).join('&amp;')
      history.push({
          pathname: props.location.pathname,
          search: serialize(params)
      })
  }
  </code></pre>