You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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!
The text was updated successfully, but these errors were encountered:
Thanks @szilagyi-sandor you are right, since React 18 won't silence the logs as React 17 does. Our current version should be compatible with React 18 but React 17 is still the major supported version, see Compatibility Matrix . Maybe we should add something like return () => { firstRun = true } for useEffect and possibly more updates for React 18 changes. Please feel free to send out a PR (but we are not sure of verion18 release date yet)
When you run your application in
development
mode and with thestrict mode
on theskipFirstRun
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 inproduction
environment, but can be confusing in dev mode.Steps to Reproduce
Use the
useTrackEvent
hook in dev mode with thestrict mode
on.Expected behavior
useTrackEvent
sskipFirstRun
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!
The text was updated successfully, but these errors were encountered: