title: React-Router: Why is the useHistory undefined in react?
body: <p>I have this.
  It is exactly the same as it says in the documentation.
  I think the react-router-dom module is fine because in other components the BrowserRouter, Router and Link work for me</p>
  <pre><code>import { useHistory } from &quot;react-router-dom&quot;
  import React from 'react'
  
  export default function HomeButton() {
    let history = useHistory()
  
    function handleClick() {
      history.push(&quot;/home&quot;)
    }
  
    return (
      &lt;button type=&quot;button&quot; onClick={handleClick}&gt;
        Go home
      &lt;/button&gt;
    );
  }
  </code></pre>
  <p>when I click the button this happens</p>
  <blockquote>
  <p>TypeError: Cannot read property 'push' of undefined</p>
  </blockquote>
  <p>I am newbie in reactjs please help, and thanks</p>