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

FR: check cookie before triggering handleExitIntent #8

Open
patshologram opened this issue Aug 17, 2023 · 0 comments
Open

FR: check cookie before triggering handleExitIntent #8

patshologram opened this issue Aug 17, 2023 · 0 comments

Comments

@patshologram
Copy link

Hello,

currently, the cookie seems to be read once when the component is mounted: https://github.com/daltonmenezes/use-exit-intent/blob/main/packages/use-exit-intent/src/index.ts#L150.

This prevents unsubscribe logic to work, if it is triggered from another part of the application. However, I don't know if this is intentional. Our use case

  • We have a nextjs application where useExitIntent is initialized in the root layout
  • We have a button near the footer where the user can willingly click to trigger the exit intend model dialog and subscribe
  • When the user manually trigger the modal, we tigger unsubscribe()
  • Due to the cookie only been read during initial mount and not inside the handler callback, the modal triggers again in certain scenarios

In this use case the check for shouldNotTrigger.current is not enough, as the exit-intent cookie won't be read again.

Any suggestions for solving this problem differently are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant