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