Skip to content

Commit

Permalink
chore(Visibility): remove usage of deprecated lifecycle methods (#3973)
Browse files Browse the repository at this point in the history
  • Loading branch information
layershifter committed Jun 29, 2020
1 parent 1d83ac1 commit 9adb4bf
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions src/behaviors/Visibility/Visibility.js
Expand Up @@ -187,22 +187,6 @@ export default class Visibility extends Component {
// Lifecycle
// ----------------------------------------

// eslint-disable-next-line camelcase
UNSAFE_componentWillReceiveProps({ continuous, once, context, updateOn }) {
const cleanHappened =
continuous !== this.props.continuous ||
once !== this.props.once ||
updateOn !== this.props.updateOn

// Heads up! We should clean up array of happened callbacks, if values of these props are changed
if (cleanHappened) this.firedCallbacks = []

if (context !== this.props.context || updateOn !== this.props.updateOn) {
this.unattachHandlers(this.props.context)
this.attachHandlers(context, updateOn)
}
}

componentDidMount() {
this.mounted = true

Expand All @@ -215,6 +199,21 @@ export default class Visibility extends Component {
if (fireOnMount) this.update()
}

componentDidUpdate(prevProps) {
const cleanHappened =
prevProps.continuous !== this.props.continuous ||
prevProps.once !== this.props.once ||
prevProps.updateOn !== this.props.updateOn

// Heads up! We should clean up array of happened callbacks, if values of these props are changed
if (cleanHappened) this.firedCallbacks = []

if (prevProps.context !== this.props.context || prevProps.updateOn !== this.props.updateOn) {
this.unattachHandlers(prevProps.context)
this.attachHandlers(this.props.context, this.props.updateOn)
}
}

componentWillUnmount() {
const { context } = this.props

Expand Down

0 comments on commit 9adb4bf

Please sign in to comment.