componentWillReceiveProps(nextProps) {
this.setState({executor : nextProps.executor, wife : nextProps.wife});
// Some filtering and functional Operation on nextProps value of wife and executor.
}
我想优化上面的代码。
最佳答案
componentWillReceiveProps(nextProps) {
const {executor, wife} = nextProps;
this.setState({executor, wife});
// Some filtering and functional Operation on nextProps value of wife and executor.
}
这样,您可以像妻子一样优化和使用变量,而无需更改任何值。