首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Redux-router:链路未触发重新呈现,但history.change正在触发

Redux-router:链路未触发重新呈现,但history.change正在触发
EN

Stack Overflow用户
提问于 2015-09-22 07:19:20
回答 1查看 821关注 0票数 0

我希望让这段代码工作,但在redux-router项目的源代码中没有通过文档或示例。我有以下代码(出于迁移原因,在/frontend中从根目录开始):

代码语言:javascript
复制
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'));

问题是,当我按下链接时,什么都不会改变,应用程序也不会重新呈现它的子项,但当我使用浏览器导航来回切换时,它就可以工作了。我哪里搞砸了?

非常感谢!

EN

回答 1

Stack Overflow用户

发布于 2015-09-22 18:18:37

更新:

替换此行:

代码语言:javascript
复制
<ReduxRouter history={history}>

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

代码语言:javascript
复制
<ReduxRouter>

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32706013

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档