Any idea why following setState for popUpBurned is not working?
componentDidMount() {
const { user } = this.props
const { popUpBurned } = this.state
const visits = user.visitsCounter
if (visits === 6 && !popUpBurned) {
this.setState({ popUpBurned: true })
this._popupFeedbackVisits.show()
}
}
I need my _popupFeedbackVisits
to trigger only once when the visit-number is 6, which works just fine. But when in the same visit, the user navigates to another page and comes back to dashboard, the popup triggers again (as the visits are still 6).
How can I make the popup to trigger once and only once? My though was to add that boolean, but it does not seems to work inside componentDidMount. What am I missing?
Thanks!
This work-around using sessionStorage solved the issue:
if (user.visitsCounter === 6 && !sessionStorage.getItem('popUpBurned')) {
sessionStorage.setItem('popUpBurned', true)
this._popupFeedbackVisits.show()
}