具有syncHistoryWithStore的路由不起作用,并且不显示错误

时间:2017-03-27 23:08:30

标签: javascript reactjs react-router react-redux react-router-redux

我正在创建路线而且我被卡在syncHistoryWithStore上,但它不起作用。控制台上没有任何错误或任何错误,它只是不加载组件。

但是,如果我只使用createBrowserHistory而没有同步它,则单击链接会更改组件

import { createBrowserHistory } from 'history';
import { syncHistoryWithStore } from 'react-router-redux';

const store = createStore(reducers, applyMiddleware(thunk));

// Doesn't work: Doesn't load components, page doesn't change (without a full reload)
// No errors on the console
const history = syncHistoryWithStore(createBrowserHistory(), store);

// Works
// const history = createBrowserHistory();

render(
  <Provider store={ store } key="provider">
    <Router history={ history }>
    ...
          <Switch>
            <Route exact path="/" component={ Home } />
            <Route path="/about" component={ About } />
            <Route path="*" component={ NoMatch }/>
          </Switch>

的package.json

"react": "^15.4.2",
"react-dom": "^15.4.2",
"react-redux": "^5.0.3",
"react-router": "^4.0.0",
"react-router-dom": "^4.0.0",
"react-router-redux": "^4.0.8",
"redux": "^3.6.0",

我有什么具体的工作要做吗?是否有一个最新版本的例子?

或者我应该在没有同步的情况下使用createBrowserHistory吗?

0 个答案:

没有答案