0

我想让这段代码工作,但没有通过文档或redux-router项目的源代码中的示例得到它。我有这段代码(出于迁移原因,在 /frontend 中以 root 开头):

class App extends Component {
  render() {
    const links = [
      '/frontend',
      '/frontend/season',
      '/frontend/episode'
    ].map(l =>
      <p>
        <Link to={l}>{l}</Link>
      </p>
    );
    console.log('render');
    return (
      <div>
        <h1>App Container</h1>
        {links}
        {this.props.children}
      </div>
    );
  }
}
App.propTypes = {
  children: PropTypes.node
};
function mapStateToProps(state) {
  return {
    routerState: state.router
  };
}
connect(mapStateToProps)(App);

const rootReducer = combineReducers({
  episode,
  router: routerStateReducer
});

const store = compose(
  reduxReactRouter({ createHistory})
)(createStore)(rootReducer,initialState);

class Root extends Component {
  render() {
    return (
      <div>
        <ReduxRouter history={history}>
          <Route path="/frontend" component={App}>
            <Route name="episode" path="episode" component={EpisodeApp} />
            <Route name="season" path="season" component={SeasonApp} />
          </Route>
        </ReduxRouter>
      </div>
    );
  }
}

React.render(
  <Provider store={store}>
    {() => <Root/>}
  </Provider>
  , document.getElementById('root'));

问题是,当我按下链接时,没有任何变化,并且应用程序不会重新呈现其子项,但是当我使用浏览器导航来回移动时,它确实可以工作。我在哪里搞砸了?

非常感谢!

4

1 回答 1

1

更新:

替换这一行:

<ReduxRouter history={history}>

通过这个(所以删除历史对象):

<ReduxRouter>

让它工作,不知道为什么。

于 2015-09-22T10:18:37.467 回答