使用的版本:
“react-router-dom”: “^4.2.2”,
“react-router-redux”: “^5.0.0-alpha.8”,
问题:
使用 BrowserRouter 包裹 则 redux store无法检测路由变化, 去掉BrowserRouter,路由变化,则页面不切换!
升级router 4后 如何关联 redux 哪位有什么好办法啊?
React-router4 ,用react-router-redux 5 关联 redux 的问题
lileilei
#1
navono
#8
我现在也遇到了路由切换,但是界面不渲染的问题。
ConnectedRouter 必须和Route在同一个组建内。
怎么理解?
我现在是这么用的:
index.jsx
const store = configureStore();
render(
<AppContainer>
<Root store={store} history={history} />
</AppContainer>,
document.getElementById('root')
);
Root.jsx
import Routes from '../routes';
const Root = ({store, history}) => (
<Provider store={store}>
<ConnectedRouter history={history}>
<Routes />
</ConnectedRouter>
</Provider>
);
export default Root;
routes.jsx
const AppPage = () => (
<App>
<Switch>
<Route path='/' component={HomePage} />
<Route path='/counter' component={CounterPage} />
</Switch>
</App>
);
export default AppPage;