React-router4 ,用react-router-redux 5 关联 redux 的问题

#1

使用的版本:
“react-router-dom”: “^4.2.2”,
“react-router-redux”: “^5.0.0-alpha.8”,
问题:
使用 BrowserRouter 包裹 则 redux store无法检测路由变化, 去掉BrowserRouter,路由变化,则页面不切换!
升级router 4后 如何关联 redux 哪位有什么好办法啊?

#2

使用了react-router-redux就不需要BrowserRouter包裹了

#3

关键是 切换路由 页面不渲染!!

#4

那可能你代码写错了,仔细看看文档

#5

是未正式发布的 react-router-redux 版本,所有有bug。

#6

我自己项目用着没问题的,不是库的原因

#7

找到问题了,ConnectedRouter 必须和Route在同一个组建内。谢谢!

#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;
#9

已經解決了。