title: How to fix a react-hooks/exhaustive-deps linting error with no dependency
body: <p>I have a linting error (<code>react-hooks/exhaustive-deps</code>) that I am currently disabling on two lines. I understand how the code is breaking the rule, but I do not understand why this rule applies to this situation. </p>
  
  <p>I want an effect to only run for cleanUp purposes when the component unmounts. I have a function, <code>clearMessages</code>, which is inherited from props which reset the state of a reducer back to its empty default state. It works fine when I run my project locally, but when I run the build react-scripts throws the above linting error and the build fails.</p>
  
  <p>Here is a short snippet showing the effect that causes the problem.</p>
  
  <pre><code>
  const Search = ({ clearMessages }) =&gt; {
  
  useEffect(() =&gt; () =&gt; clearMessages(), [])
  
  ...
  ...
  
  }
  
  </code></pre>
  
  <p>This is the error message that react-scripts build throws.</p>
  
  <blockquote>
    <p>Line 25:  React Hook useEffect has a missing dependency:
    'clearMessages'. Either include it or remove the dependency array. If
    'clearMessages' changes too often, find the parent component that
    defines it and wrap that definition in useCallback 
    react-hooks/exhaustive-deps</p>
  </blockquote>
  
  <p>I would not expect <code>clearMessages</code> to change, so I am not sure why it is important that I provide it as a dependency. I do not want the effect to the only run when the value of <code>clearMessages</code> changes.</p>