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
Since the authentication logic is contained withing the AuthProvider, accessing access token requires the useContext hook. React forbids using hook outside of a function component. That said, we cannot get the token in our services (rtk queries). The workaround currently is to pass the token to the query/mutation function as a parameter which is not ideal due to duplicated code. Instead of using native react context, we can store authentication info in a redux slice and consume the state by calling getState when defining any query/mutation.
The text was updated successfully, but these errors were encountered:
Description
Since the authentication logic is contained withing the
AuthProvider
, accessing access token requires theuseContext
hook. React forbids using hook outside of a function component. That said, we cannot get the token in our services (rtk queries). The workaround currently is to pass the token to the query/mutation function as a parameter which is not ideal due to duplicated code. Instead of using native react context, we can store authentication info in a redux slice and consume the state by callinggetState
when defining any query/mutation.The text was updated successfully, but these errors were encountered: