Skip to content

getToken changes after each render #201

Closed

Description

@marjan-pluto

Package + Version

  • @clerk/clerk-js
  • @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:
image

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

It would be ideal if getToken can be made stable as it was in v2.

Activity

  1. self-assigned this
    on Apr 18, 2022
  2. nikosdouvlis commented on Apr 29, 2022

    @nikosdouvlis
    Member

    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!

  3. waldothedeveloper commented on Feb 22, 2023

    @waldothedeveloper
    Contributor

    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

  4. dimkl commented on Feb 28, 2023

    @dimkl
    Contributor

    @waldothedeveloper thank you for reporting it. We have updated our docs.

  5. rjdellecese commented on Feb 28, 2023

    @rjdellecese

    The problem described by this issue hasn't been resolved, has it? If not, it seems to me like this issue should remain open.

  6. reopened this on Mar 15, 2023
  7. nikosdouvlis commented on Mar 24, 2023

    @nikosdouvlis
    Member

    Hello everyone, the fix will be shipped with our next release.

  8. locked as resolved and limited conversation to collaborators on Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions