title: How To Access History in React With React-Router 6
body: <p>I am using React-Router 6 alpha, and I would like to disable the browser &quot;Back&quot; button by:</p>
  <ul>
  <li>Detecting the back event, and</li>
  <li>On detection, using the history to immediately send the browser forward.</li>
  </ul>
  <p>In React-Router 5, this would accomplished with the following code in App.js:</p>
  <pre><code>window.addEventListener(&quot;popstate&quot;, () =&gt; {
    history.go(1);
  }); 
  </code></pre>
  <p>...while also using the following</p>
  <pre><code>import { withRouter } from &quot;react-router&quot;;
  
  class Comp1 extends React.Component { 
      lots of stuff 
  }
  export default withRouter(Comp1)
  </code></pre>
  <p>The problem is... there is no <code>withRouter</code>, anymore. There's nothing to wrap the export in, and consequently no access to the history that I can see.  How can I get access to that history, if it's possible at all?  I can still detect the Back button event (an alert box proves that) but I can't see how to move forward by one.</p>
  <p>(Ignore for the moment that this implementation obliterates any state held in the component-- I'm just trying to get my arms around this.)</p>