子组件正在从其父组件接收许多更新的道具。如果道具中有任何更新,我想更新子组件。当前,我正在使用生命周期方法进行更新
componentWillReceiveProps
一切如期而至。
componentWillReceiveProps(nextProps){
if(this.props.scale_length !== nextProps.scale_length){
const {scale_height,scale_breadth} = this.props
this.setState({
torsoScale: new
THREE.Vector3(nextProps.scale_length,scale_height,scale_breadth)
});
}
if(this.props.scale_breadth !== nextProps.scale_breadth){
const {scale_height,scale_length} = this.props
this.setState({
torsoScale: new
THREE.Vector3(scale_length,scale_height,nextProps.scale_breadth)
});
}
...
}
但是,我以后会得到8个以上的道具。我该怎么做呢。谢谢。