0

When loading for the first time the content is displayed correctly, clicking a link will change the URL but the view still the same. I had to click twice for the view to change.

My router

render(
<Provider store={store}>
    <Router history={browserHistory}>
        <Route path="/:courseName/**" component={components.app}>
            <IndexRoute components={{
                sidebar: containers.sidebar,
                chapter: containers.chapter
            }} />
        </Route>
    </Router>
</Provider>,
document.getElementById('container')
);

My dispatch inside the chapter component

componentWillUpdate() {
    const { dispatch, params: { courseName, splat } }  = this.props;
    dispatch(actions.fetchChapter(courseName, splat));
sandaemc
  • 81
  • 7
  • 1
    That's it because you're working with the "old" props. Try to use the newest ones with something like this.`componentWillUpdate(props) { const { dispatch, params: { courseName, splat } } = props; dispatch(actions.fetchChapter(courseName, splat));` – dlopez Jan 31 '17 at 16:54
  • Thank you @dlopez! – sandaemc Jan 31 '17 at 17:02

1 Answers1

0

As @dlopez pointed out, I had to use the incoming props.

componentWillReceiveProps(nextProps) {
    console.log("In erhe");
    const { dispatch, params: { courseName, splat } }  = nextProps;
    dispatch(actions.fetchChapter(courseName, splat));
}
sandaemc
  • 81
  • 7