title: getting an error related to react hook useHistory
body: <p>I have implemented useHistory() same as i implemented below , previously i didnt get any error but in this compmonent i am getting an error as</p>
  <blockquote>
  <p>Line 6:18:  React Hook &quot;useHistory&quot; is called in function &quot;showPost&quot; which is neither a React function component or a custom React Hook function  react-hooks/rules-of-hooks</p>
  </blockquote>
  <pre><code>import React from 'react';
  import CloseIcon from '@material-ui/icons/Close';
  import {useHistory} from 'react-router-dom';
  
  const showPost = () =&gt;{
      let history = useHistory();
  
      const closeUpload = () =&gt;{
          history.goBack();
      }
  
      return(
          &lt;div className=&quot;overlay&quot;&gt;
              &lt;div className=&quot;overlay-container&quot;&gt;
                  &lt;button className=&quot;close-btn&quot; onClick = {closeUpload}&gt;&lt;CloseIcon color=&quot;action&quot;/&gt;&lt;/button&gt;
                  &lt;h1&gt;Hello&lt;/h1&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      );
  }
  
  export default showPost;
  </code></pre>
  <p>please, help me in solving this.
  thank you in advance.</p>