history icon indicating copy to clipboard operation
history copied to clipboard

blank page when pushing to hash history after upgrading from v4 to v5

Open joao-mambelli opened this issue 3 years ago • 3 comments

Did something change for v5? Am I missing something?

If I go back to 4.10.1, pushing a path to history works fine, in v5 it gives me a blank page. If then I reload the browser, only then it shows the page.

index.js

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

import Home from '../../views/home/home';
import Login from '../../views/login/login';

import routerHistory from './routerHistory';

import { Provider } from 'react-redux';
import store from '../redux/store';

import GlobalStyle from  '../styles/styles'

//Routes
export default function Routes() {
  return (
    <Provider store={store}>
      <Router history={routerHistory}>
        <Switch>
          <Route path="/" exact component={Home} />
          <Route path="/login" component={Login}/>
        </Switch>
        <GlobalStyle />
      </Router>
    </Provider>
  );
}

routerHistory.js

import { createHashHistory } from 'history';

export default createHashHistory();

in some file:

import routerHistory from '../../core/infrastructure/routerHistory';

...
routerHistory.push("/");
...

joao-mambelli avatar Dec 23 '21 08:12 joao-mambelli

I'm having the same issue. Can you provide your package.json? Might be some incompatibility with react-router-dom or redux. I'll let you updated if I find anything.

edilsonborges avatar May 04 '22 04:05 edilsonborges

Same issue here. We have upgraded history to v5 but kept react-router to version v5 (and not upgraded to v6), perhaps is this the reason ?

abenhamdine avatar Mar 20 '23 10:03 abenhamdine

Same issue here. We have upgraded history to v5 but kept react-router to version v5 (and not upgraded to v6), perhaps is this the reason ?

Indeed, it works with RR6

abenhamdine avatar Mar 22 '23 09:03 abenhamdine