首页 > 代码库 > react componentWillReceiveProps

react componentWillReceiveProps

componentWillReceiveProps(nextProps){
不加判断 会可能导致组件本身 setState不生效
if(nextProps.isPersonEdit !==this.props.isPersonEdit){
if(‘isPersonEdit‘ in nextProps){
this.setState({isEdit:nextProps.isPersonEdit})
}
}
}
handleSelect(value,option){
this.setState({isEdit:true})
}

react componentWillReceiveProps