作者:镜头拿反的葛小峥给_523 | 来源:互联网 | 2023-02-01 19:04
1> Shubham Khat..:
ComponentDidMount
在组件安装时,lifeCycle函数仅执行一次。你想要的是componentWillReceiveProps
每次道具更改都会执行功能
做这个
componentDidMount() {
if (this.props.user_positions[0] ) {
this.props.dispatch(loadJobTitleSkills(this.props.user_positions[0].job_title_id));
}
}
componentWillReceiveProps(nextProps) {
if (this.props.user_positions[0] !== nextProps.userPositions[0]) {
this.props.dispatch(loadJobTitleSkills(this.props.user_positions[0].job_title_id));
}
}