Closed eric-burel closed 7 years ago
Looks like the issue may be that you aren't saving the handler again in handleClose()
try changing it to something like
handleClose(){
// we set the modal again, so that it reopens when we quit next time
const handler = this.setupOuibounce()
this.setState({open:false, handler})
}
Definitely the right solution, thanks. I should have posted on stackoverflow first. I'll try to publish a React version of ouibounce some day.
Hi guys,
I am trying to wrap
ouibounce
into a React component. It works mostly fine (thanks for this great package btw), however I can't unmount cleanly.Here is how my component works :
ouibounce
on the root DOM element of the componenthandler.disable()
disable()
function is indeed called. Nowouibounce
should be disabledHowever it is not disabled, the callback is still fired when an exit intent is detected eventhough my
OnExitModal
component is unmounted. This leads to a small (but annoying when I see it 57 times a day) React error message, since I am setting state of an unmounted component.Any React user there with an idea :) ?
Here is the complete code :