title: Trigger logout custom hook
body: <p>I'm trying to build a custom hooks on my app, here is my code:</p>
  <pre><code>import { useContext } from 'react'
  import { UserContext } from '../components/context/UserContext'
  import { useHistory } from &quot;react-router-dom&quot;;
  
  const useLogout = () =&gt; {
      const [, setUser] = useContext(UserContext);
      let history = useHistory()
      setUser(null);
      history.push('/login')
  }
  
  export default useLogout;
  </code></pre>
  <p>This is easy to understand, when I trigger my <code>useLogout</code> I want to delete information about my current user and then redirect my user to login page.</p>
  <p>So then, I have a Navbar component with a logout button. And I want to my custom hook to fire when I click on my logout button:</p>
  <pre><code>...
  &lt;Logout onClick={useLogout} /&gt;
  </code></pre>
  <p>When I click, I get an error saying this
  <a href="https://i.stack.imgur.com/HvvRO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HvvRO.png" alt="enter image description here" /></a></p>
  <p>I don't get it because I'm in a React component when I fire the hook, and all my component are functionnal components.</p>
  <p>So what is the part I didn't understood about custom hooks here ?</p>