Skip to content

Commit

Permalink
fix(index.js): Replaced the deprecated componentWillReceiveProps.
Browse files Browse the repository at this point in the history
  • Loading branch information
jackall3n committed Jun 24, 2019
1 parent 34fa8cb commit 80b71ed
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 80b71ed

Please sign in to comment.