方法二在项目中的实际应用
父组件中:
onSubmitShare = () => {
this.setState({
submitCheck: this.state.submitCheck + 1,
});
};
子组件中:
UNSAFE_componentWillReceiveProps(nextProps) {
if (this.props.submitCheck !== nextProps.submitCheck) {
this.handleShareSubmit();
}
};