在升级到16.3
版之前,我会根据props 的变化调用一个方法,如下所示:
componentWillReceiveProps(nextProps){
if(this.props.country.length !== nextProps.country){
doSomething(); //example calling redux action
}
}
componentWillReceiveProps
在16.3
版上不安全,我们必须使用getDerivedStateFromProps
.然而,这个方法返回一个对象,我不知道如何从内部调用一个方法,就像在componentWillReceiveProps
中那样