Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(Visibility): remove usage of deprecated lifecycle methods #3973

Merged
merged 1 commit into from Jun 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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