需要的包
"query-string": "5.1.1",
"react-router-dom": "4.3.1",
"connected-react-router": "5.0.1",
关键变更
- react-router 4 不再 parse location.search,需要手动用
query-string解析 - 没有
params/routeParams了,改用match.params - Route 写法变化:使用
<Route path="/home" render={...} /> - history 独立管理:
import createHistory from 'history/createBrowserHistory'
业务代码迁移
// 之前
import { browserHistory } from "react-router";
browserHistory.push("xxx");
// 之后
import history from "js/redux/middleware/history";
history.push("xxx");