fix: Use getDerivedStateFromProps instead of componentWillReceiveProps (#372)
* use getDerivedStateFromProps instead of componentWillReceiveProps * code formattingnolan/no-underscore-json
parent
f10510b262
commit
208099c2dc
|
@ -176,12 +176,19 @@ export default class NimblePicker extends React.PureComponent {
|
|||
this.handleKeyDown = this.handleKeyDown.bind(this)
|
||||
}
|
||||
|
||||
componentWillReceiveProps(props) {
|
||||
static getDerivedStateFromProps(props, state) {
|
||||
if (props.skin) {
|
||||
this.setState({ skin: props.skin })
|
||||
} else if (props.defaultSkin && !store.get('skin')) {
|
||||
this.setState({ skin: props.defaultSkin })
|
||||
return {
|
||||
...state,
|
||||
skin: props.skin,
|
||||
}
|
||||
} else if (props.defaultSkin && !store.get('skin')) {
|
||||
return {
|
||||
...state,
|
||||
skin: props.defaultSkin,
|
||||
}
|
||||
}
|
||||
return state
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
|
|
Loading…
Reference in New Issue