react has been upgraded to version 16.3.2
"react": "^16.3.2",
"react-dom": "^16.3.2",
method rewriting:
// brfore
componentWillReceiveProps(nextProps: Props) {
console.log(nextProps);
this.setState({
value: setCurrentStyleToSelect(nextProps, this.props.regex, this.props.defaultValue),
});
}
// now
static getDerivedStateFromProps(nextProps: Props, prevState: Props) {
console.log(nextProps);
console.log(prevState);
if (nextProps !== prevState) {
return {
value: setCurrentStyleToSelect(
nextProps,
prevState.regex,
prevState.defaultValue,
),
};
}
return null;
}
the current console cannot be entered; none of the methods in getDerivedStateFromProps have been executed