react-redux-realworld-example-app icon indicating copy to clipboard operation
react-redux-realworld-example-app copied to clipboard

Loading wrong article ? this.props.match... vs nextProps.match...

Open PeterKneale opened this issue 6 years ago • 0 comments

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

PeterKneale avatar Mar 02 '18 10:03 PeterKneale