title: Is there a way to use history with HashRouter, with react-router v4?
body: <p>I have need to redirect a user outside of a React component, which typically is done using <code>history</code> with react-router.</p>
  <pre><code>// history.js
  const history = createBrowserHistory();
  export default history;
  
  // App, setting up router
  import { HashRouter as Router } from 'react-router-dom';
  import history from './history';
  ...
  &lt;HashRouter history={history}&gt;...&lt;/HashRouter&gt; // problem
  
  // Non-component file
  import history from './history';
  history.push('/target');
  </code></pre>
  <p>Since <code>HashRouter</code> doesn't take a history prop, but rather handles history internally, and developers are directed to use <code>withRouter</code> in order to expose <code>history</code> to a component, it's not apparent how to do redirects outside of a component.</p>
  <p>I am using <code>HashRouter</code> <em>and</em> I need to use the <code>history</code> outside of a component (meaning I can't use <code>withRouter</code>).</p>
  <p>How could I make this happen?</p>