Recoil with JWT Authentication - Avoid re-render #1853
Unanswered
techknowfile
asked this question in
Q&A
Replies: 1 comment
-
If you are using the token to initialize the User object which is an atom then you may want to use an Atom Effect for the initialization. Atom Effects can initialize the state of an atom and reference other atoms without subscribing to them. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm using OAuth2/OIDC for AuthN/AuthZ, which returns a JWT accessToken with user details.
I use this token to initialize my User object, and it is also sent as an
Authorization
header in the requests to the backend.The problem is that this token only lasts 15 minutes, so a refreshToken is used to update the accessToken. With my current setup, User is a single atom, so every time the accessToken is refreshed, everything dependent on the user (the entire app) re-renders.
Is there a standard way to prevent re-rendering in situations such as this? Will I need to separate the accessToken out from the user, and then programmatically update the User atom with an accessToken atom for only the changed values?
Beta Was this translation helpful? Give feedback.
All reactions