【发布时间】:2018-04-15 15:48:42
【问题描述】:
版本:“react-router-dom”:“^4.1.2”, "react-router-redux": "^5.0.0-alpha.8",
我可以通过这种方式在我的组件中成功导航路由器:
this.props.history.push('/cart')
然后我想在我的 saga.js 中导航路由器,我尝试了一些方法,但它们都不起作用:
const history = createHistory();
yield call(history.push, '/cart')
yield call(put('/cart)//react-router-redux
history.push('/cart')
这些方法可以改变 url ,但页面不会呈现。 我用Router添加了页面组件,它也不起作用。 谁能帮帮我谢谢!
这是我的一些设置:
const render = Component =>
ReactDOM.render(
<Provider store={store}>
<AppContainer>
<Component />
</AppContainer>
</Provider>
,
document.getElementById('root')
);
class App extends Component {
render () {
return (
<ConnectedRouter history={history}>
<div>
<Header/>
<Nav/>
<ScrollToTop>
<Route render={({location}) => (
<ReactCSSTransitionGroup
transitionName="fade"
transitionEnterTimeout={300}
transitionLeaveTimeout={300}>
<div key={location.pathname} className="body">
<Route location={location} exact path="/" component={HomePageContainer}/>
<the other component>
.....
</div>
</ReactCSSTransitionGroup>)}/>
</ScrollToTop>
<Footer/>
</div>
</ConnectedRouter>
)
}
}
================================================ ================
我通过这种方式解决了这个问题:用户路由器而不是 BroswerRouter,然后
history.push('/somerouter')
【问题讨论】:
-
是的,我已经看到了这个问题,但它对我不起作用,页面不会呈现
标签: reactjs react-router jsx redux-saga react-router-redux