react-redux-realworld-example-app
react-redux-realworld-example-app copied to clipboard
Loading wrong article ? this.props.match... vs nextProps.match...
Shouldn't this snippet be loading the article pointed to by nextProps.match.params.slug
rather than this.props.match.params.slug
.
I'm admittedly using this app as a reference while learning react but surely nextProps...
is pointing to the one being navigated to rather than this.props..
which is the one currently being viewed.
componentWillReceiveProps(nextProps) {
if (this.props.match.params.slug !== nextProps.match.params.slug) {
if (nextProps.match.params.slug) {
this.props.onUnload();
return this.props.onLoad(agent.Articles.get(this.props.match.params.slug));
}
this.props.onLoad(null);
}
}
https://github.com/gothinkster/react-redux-realworld-example-app/blob/master/src/components/Editor.js#L77