title: 'React Hook useEffect has a missing dependency' warning with function
body: <p>So I have this React component which uses the useEffect() hook:</p>
  
  <pre><code>const [stateItem, setStateItem] = useState(0);
  
  useEffect(() =&gt; {
    if (condition) {
      myFunction();
    }
  }, [stateItem]);
  
  const myFunction = () =&gt; {
    return 'hello';
  }
  </code></pre>
  
  <p>React gives me a warning about 'myFunction' being a missing dependency. I (think I) understand why and I've read through many similar questions asking for more or less the same thing, but the answer is always 'move your function into the useEffect hook'. This would be fine if not for myFunction being called from different places, e.g.:</p>
  
  <pre><code>...
  return (
    &lt;Button onClick={() =&gt; myFunction()} /&gt;
  );
  </code></pre>
  
  <p>therefore I cannot put my function inside the useEffect hook.</p>
  
  <p>One answer to a similar question was to put the function outside the component, but that would require me to pass a lot of data to my functions, e.g.
  <code>const myFunction(stateItem, setStateItem, someProp) =&gt; { stuff };</code></p>
  
  <p>which gets extremely tedious when there are several functions with many props, state hooks etc. to pass.</p>
  
  <p>Aside from putting a linter ignore comment above the useEffect hook, is there anything more practical to do about this? I'm finding these things to make using react hooks very impractical.</p>