Skip to content

Commit

Permalink
fix: Use getDerivedStateFromProps instead of componentWillReceiveProps (
Browse files Browse the repository at this point in the history
#372)

* use getDerivedStateFromProps instead of componentWillReceiveProps

* code formatting
  • Loading branch information
h6ak authored and nolanlawson committed Dec 21, 2019
1 parent f10510b commit 208099c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/components/picker/nimble-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
return {
...state,
skin: props.skin,
}
} else if (props.defaultSkin && !store.get('skin')) {
this.setState({ skin: props.defaultSkin })
return {
...state,
skin: props.defaultSkin,
}
}
return state
}

componentDidMount() {
Expand Down

0 comments on commit 208099c

Please sign in to comment.