remix-run / history

Manage session history with JavaScript
MIT License
8.29k stars 961 forks source link

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

Open joao-mambelli opened 2 years ago

joao-mambelli commented 2 years ago

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("/");
...
edilsonborges commented 2 years ago

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.

abenhamdine commented 1 year ago

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 commented 1 year ago

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