daltonmenezes / use-exit-intent

🐠 A React Hook to handle exit intent strategies
https://use-exit-intent.daltonmenezes.com
MIT License
83 stars 6 forks source link

FR: check cookie before triggering handleExitIntent #8

Open patshologram opened 1 year ago

patshologram commented 1 year ago

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

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.