connected-react-router icon indicating copy to clipboard operation
connected-react-router copied to clipboard

Doesn't work properly with "history" v5.0.0

Open simpleman383 opened this issue 4 years ago • 2 comments

In case of bundling the latest version of "connected-react-router" with the "history" package at version 5.0.0, the router doesn't seem to react to the changes of the history object: redux actions (dispatching with push("/some-route")) and clicks on <Link /> component lead to the change of browser's URL but do not re-render the affected component.

Such behaviour can be observed even in the example projects provided in the repository (e.g. "basic" project https://github.com/supasate/connected-react-router/tree/master/examples/basic).

Example

  1. Modified dependency list of the "basic" project (https://github.com/supasate/connected-react-router/tree/master/examples/basic) with history v5.0.0
{
  "name": "connected-react-router-example-basic",
  "version": "1.0.0",
  "description": "A basic example for Connected React Router",
  "main": "src/index.js",
  "scripts": {
    "dev": "node server.js",
    "build": "webpack --mode production"
  },
  "author": "Supasate Choochaisri",
  "license": "MIT",
  "devDependencies": {
    "@babel/core": "^7.1.2",
    "@babel/preset-env": "^7.1.0",
    "@babel/preset-react": "^7.0.0",
    "babel-cli": "^6.26.0",
    "babel-loader": "^8.0.4",
    "express": "^4.16.4",
    "react-hot-loader": "^4.3.12",
    "webpack": "^4.24.0",
    "webpack-cli": "^3.1.2",
    "webpack-dev-middleware": "^3.4.0",
    "webpack-hot-middleware": "^2.24.3"
  },
  "dependencies": {
    "connected-react-router": "^6.0.0",
    "history": "^5.0.0",
    "prop-types": "^15.6.2",
    "react": "^16.6.0",
    "react-dom": "^16.6.0",
    "react-redux": "^6.0.0",
    "react-router": "^4.3.1",
    "react-router-dom": "^4.3.1",
    "redux": "^4.0.1"
  }
}
  1. Application behaviour

image

simpleman383 avatar Mar 10 '21 16:03 simpleman383

This is an upstream problem - React Router doesn't support history v5 yet. https://github.com/ReactTraining/history/issues/804

alexplumb avatar Mar 16 '21 14:03 alexplumb

If you are starting a new project, you can try lagunovsky/redux-react-router based on React Router v6 and History v5

lagunovsky avatar Jun 16 '21 17:06 lagunovsky