When you run your application in development mode and with the strict mode on the skipFirstRun parameter is not working properly. The reason for this is that when the strict mode tries to identifying unsafe lifecycles it will rerender your component making it call the function twice by default. This is not going to happen in production environment, but can be confusing in dev mode.
Steps to Reproduce
- OS/Browser: Windows/Chrome
- React Version: 18.2.0
Use the useTrackEvent hook in dev mode with the strict mode on.
Expected behavior
useTrackEvents skipFirstRun parameter works properly in development with strict mode.
Additional context
To prevent this issue, all you need to do is set the firstRun variable back to true, when the hook unmounts. I can create a PR for this if you want.
Thanks!