Skip to content

Commit 80b71ed

Browse files
committed
fix(index.js): Replaced the deprecated componentWillReceiveProps.
1 parent 34fa8cb commit 80b71ed

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/index.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,18 @@ class ReactTooltip extends React.Component {
133133
this.bindWindowEvents(resizeHide) // Bind global event for static method
134134
}
135135

136-
componentWillReceiveProps (props) {
137-
const { ariaProps } = this.state
138-
const newAriaProps = parseAria(props)
139-
136+
static getDerivedStateFromProps (nextProps, prevState) {
137+
const { ariaProps } = prevState
138+
const newAriaProps = parseAria(nextProps)
140139
const isChanged = Object.keys(newAriaProps).some(props => {
141140
return newAriaProps[props] !== ariaProps[props]
142141
})
143-
if (isChanged) {
144-
this.setState({ ariaProps: newAriaProps })
142+
if (!isChanged) {
143+
return null
144+
}
145+
return {
146+
...prevState,
147+
ariaProps: newAriaProps
145148
}
146149
}
147150

0 commit comments

Comments
 (0)