getToken changes after each render
- [X] Review the documentation: https://docs.clerk.dev/
- [X] Search for existing issues: https://github.com/clerkinc/javascript/issues
- [X] Go through package changelog files.
- [ ] Provide the Frontend API key from your application dashboard.
Package + Version
- [ ]
@clerk/clerk-js - [X]
@clerk/clerk-react - [ ]
@clerk/nextjs - [ ]
@clerk/remix - [ ]
@clerk/clerk-expo - [ ]
@clerk/backend-core - [ ]
@clerk/clerk-sdk-node - [ ]
@clerk/edge - [ ] other:
Version:
^3.2.7
Browser/OS
Chrome latest
Description
We started migrating to v3 and noticed getToken from useAuth function identity is not stable and as a result changes after each re-render.
This causes the the app to go into infinite loop when getToken is used in the dependancy array of something like useEffect.
Usage Snippet:

A workaround is to remove it from the dependancy array, however that does not make eslint happy

It would be ideal if getToken can be made stable as it was in v2.
Hello @marjan-pluto ! Many thanks for reporting this one :)
getToken doesn't need to be in the dependency array, but I can see why this is problematic. Your comment about eslint makes perfect sense.
I'll be working on this during the next few days, and I'll ping you here when we push a fix. Thanks again!
if getToken is not needed, update the docs folks until this is resolved...I was trying to setState following the example from the docs below and I was getting an infinite loop because of the getToken...
https://clerk.dev/docs/integration/firebase#:~:text=29-,%7D%2C%20%5BgetToken%5D)%3B,-30
@waldothedeveloper thank you for reporting it. We have updated our docs.
The problem described by this issue hasn't been resolved, has it? If not, it seems to me like this issue should remain open.
Hello everyone, the fix will be shipped with our next release.