history icon indicating copy to clipboard operation
history copied to clipboard

history.push() stopped working after upgrading to v5

Open saadbinsaeed opened this issue 4 years ago • 8 comments

I have recently upgraded history module from 4.10.1 to 5.0.0 and noticed that history.push() stopped working. After reverting it back to v4 it starts working.

Using hash history with react-router-redux

saadbinsaeed avatar Jun 16 '20 18:06 saadbinsaeed

Same issue: Uncaught Could not find router reducer in state tree, it must be mounted under "router"

etc-tiago avatar Jun 16 '20 19:06 etc-tiago

I am facing the same issue. Its look like there is some issue in the newest version "5.0.0" of history package. For now we can change its version to "4.10.1" which works for me. Use bellow command for chnage history version npm install [email protected]

PulkitAgg avatar Jun 17 '20 06:06 PulkitAgg

Looks like a duplicate of #803

mrlubos avatar Jun 17 '20 09:06 mrlubos

Here is the minimal code to reproduce this issue in the browser:

import React from 'react'
import { Router, Switch, Route } from 'react-router-dom'
import { createBrowserHistory } from 'history'

const history = createBrowserHistory()

export default () => (
  <Router history={history}>
    <Switch>
      <Route path="/target">
        <h2>Target</h2>
      </Route>
      <Route path="/">
        <h2>Home</h2>
        <button onClick={() => history.push('/target')}>Push</button>
      </Route>
    </Switch>
  </Router>
)

URL is changed, but it seems that no route is matched after history.push.

Downgrading to [email protected] fixed the problem.

nikdo avatar Jun 18 '20 10:06 nikdo

Duplicate of #804 and #803

avindra avatar Jun 19 '20 19:06 avindra

same thing, we are using hash router and history.push() is no longer working

danutzcodrescu avatar Jul 07 '20 09:07 danutzcodrescu

Have you guys check the migration list?

https://github.com/ReactTraining/react-router/blob/dev/docs/advanced-guides/migrating-5-to-6.md

brendonco avatar Aug 14 '20 05:08 brendonco

@brendonco I think this issue is regarding upgrading to v5, not v6

mrlubos avatar Aug 14 '20 06:08 mrlubos