Skip to content

Instantly share code, notes, and snippets.

@shahab65
Last active May 1, 2019 13:20
Show Gist options
  • Save shahab65/d78917f7cec9dab945e7e951630cfae9 to your computer and use it in GitHub Desktop.
Save shahab65/d78917f7cec9dab945e7e951630cfae9 to your computer and use it in GitHub Desktop.
yarn add history
import createHistory from 'history/createBrowserHistory';
export const history = createHistory();
<Router history={history}>

above code has warning so I changed it to this:

import { createBrowserHistory } from 'history';
export const history = createBrowserHistory();

BrowserRouter does not refresh after pushing with history so we should not import BrowserRouter from react-router-dom. we can import Router liks this:

import {Router, Route, Switch} from 'react-router-dom';

so we can wrap all of it in this:

yarn add history
import { createBrowserHistory } from 'history';
export const history = createBrowserHistory();
<Router history={history}>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment