Skip to content

Commit

Permalink
Merge pull request #487 from jackall3n/master
Browse files Browse the repository at this point in the history
fix(index.js): Replaced the deprecated `componentWillPeceiveProps`.
  • Loading branch information
aronhelser authored Aug 29, 2019
2 parents 34fa8cb + 80b71ed commit cfd5997
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,18 @@ class ReactTooltip extends React.Component {
this.bindWindowEvents(resizeHide) // Bind global event for static method
}

componentWillReceiveProps (props) {
const { ariaProps } = this.state
const newAriaProps = parseAria(props)

static getDerivedStateFromProps (nextProps, prevState) {
const { ariaProps } = prevState
const newAriaProps = parseAria(nextProps)
const isChanged = Object.keys(newAriaProps).some(props => {
return newAriaProps[props] !== ariaProps[props]
})
if (isChanged) {
this.setState({ ariaProps: newAriaProps })
if (!isChanged) {
return null
}
return {
...prevState,
ariaProps: newAriaProps
}
}

Expand Down

0 comments on commit cfd5997

Please sign in to comment.