version: "react-router-dom": "^4.1.2", "react-router-redux": "^5.0.0-alpha.8",
i can navigate router successfully in my component by this way:
this.props.history.push('/cart')
then i wanna navigate router in my saga.js , i tried some ways and they all not worked:
const history = createHistory();
yield call(history.push, '/cart')
yield call(put('/cart)//react-router-redux
history.push('/cart')
these ways can change the url , but the page would not render. i add the page component withRouter , and it also not work. can someone help me thanks!
here is my some settings:
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>
)
}
}
===============================================================
i fixed this problem by this way: user Router instead of BroswerRouter,and then
history.push('/somerouter')
You can use push method from react-router-redux. For example:
import { push } from "react-router-redux";
yield put(push('/')); /* inside saga generator function*/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With