Reactjs 来自componentWillMount的Redux路由器无限循环

Reactjs 来自componentWillMount的Redux路由器无限循环,reactjs,redux,Reactjs,Redux,我有以下代码 componentWillMount(){ this.props.getCourse(null, this.props.location.query.course_id); } componentWillReceiveProps(nextProps) { var currCourse_id = this.props.course_details.course_id; var nextCourse_id = this.props.location.q

我有以下代码

componentWillMount(){
    this.props.getCourse(null, this.props.location.query.course_id);
  }

  componentWillReceiveProps(nextProps) {
    var currCourse_id = this.props.course_details.course_id;
    var nextCourse_id = this.props.location.query.course_id;
    if (nextCourse_id !== currCourse_id) {
      this.props.getCourse(null, nextCourse_id);
    }
  }

我在CWRP函数中尝试了各种组合,但最终得到了一个无限循环。不过,屏幕会切换到新课程。任何关于在
currCourse\u id
nextCourse\u id
中添加内容的建议都会很有帮助。我正在尝试调度
getCourse
操作(这是一个API端点)并用新的道具更新组件。

尝试更改此行-

var nextCourse_id = nextProps.location.query.course_id;

nextProps没有任何用处。这是故意的吗?我还必须将
课程id
更改为
this.props.location.query.course\u id