react-auth-kit
react-auth-kit copied to clipboard
useIsAuthenticated hook doesn't cause re-render
Hello. As in the title the useIsAuthenticated hook won't cause component's re-render.
I've got the same problem. Please fix it quickly! :(
Hey can you please elaborate what your intended behaviour is? I am sorry, but I can't understand
I think I can explain. At least for my use case, when the auth state changes, my router redirects automatically without the need of an explicit redirect, why? because with useIsAuthenticated
hook I can conditionally render what I need if the user is signed in or not, but since v3 this hook which is expected to trigger a rerender because it is a state handler which changes if the user is auth or not the automatic redirect I got working with v2 is not working with v3.
So basically the hook isn't getting the last value automatically, you need to refresh the page to get the latest auth state.
@imjulianeral Let's have an in-person call. Please setup a call best on your time https://calendly.com/arkadip/react-auth-kit
Same problem here - can help if needed
@darkmatter18 Sure thing!
This is a repo which reproduces this issue.
https://github.com/imjulianeral/react-auth-kit-state-bug
Any update on this? @darkmatter18? Using "@auth-kit/react-router": "^3.0.2-alpha.19"
none of the hooks singIn/signOut causes rerender of useIsAuthenticated()
. As @imjulianeral mentioned - windows muset be reloaded in order to get the state.
I think i'm having the same issue. I'm using react-auth-kit 3.1.2
Before logging in:
Afte logging in, the cookies are set but nothing rerendered:
After refreshing the page manually
I have the same problem. Is there any new update?
I don't think anything will change. It seems the current version doesn't use state so there is no state update.
I draw this conclusion from this: https://github.com/react-auth-kit/react-auth-kit/issues/1558
@kennethhaspeel Wow, that's not what the mantainer said to me on our meet. Maybe the right move is to stick with v2.
Hi.
For those who still on version 3.1.2 and still get this issue, please make sure, you are invoking the useIsAuthenticated hook correctly.
When you use it like this :
const isAuthenticated = useIsAuthenticated();
it won't return you the result of you auth state, but instead it returns you function, so to fix it you should invoke it twice:
const isAuthenticated = useIsAuthenticated()();
here is the fixed commit : https://github.com/react-auth-kit/react-auth-kit/commit/bde86eff757defe26a6266ea05e287f94836ef8c
or just update the package and i hope it will work.
Thanks.
I have the same problem. Is there any new update?
The fix is coded on the master branch. Please wait for few more days for upcoming release
Is there a temporary workaround we can use before V4 release?
Is there a temporary workaround we can use before V4 release?
Have you tried the workaround @Odinaev444 mentioned? I'm not using this in my current project anymore (but will use it in future projects) so not sure if it works for your problem but I remember it working for me two months ago
I also have a similar problem...
Will the fix of this issue be released any day?
i have the same problem, has anybody fixed it?