Closed coderscode2 closed 2 months ago
@thomasheartman Can you please let me know if and when you have any update on this issue?
For others experiencing this issue and using react, I found a workaround in the meantime by swapping the useFlag
hook for directly accessing the flag value from the FlagsContext
:
import {useFlag, FlagContext} from '@unleash/proxy-client-react';
-const myFlag = useFlag('flag-name');
+const {isEnabled} = useContext(FlagContext);
+const myFlag = isEnabled('flag-name');
The issue seems to be that the update
event, which seems to be consistently emitting when its supposed to, sometimes fails to actually invoke the callback that the react library is using in the useFlag
hook
Hello @coderscode2! One question that came up as we were looking at this: are you awaiting the update of the context? It's an async method that communicates with the server, so it needs to be awaited
@daveleek Yes, I am using await but it still returns incorrect value
Ok thank you @coderscode2! we'll have a look!
Describe the bug
I have a feature toggle
xyz
and its value is true for userId 123.Right after user logs in successfully, we update the context with userId. The
xyz
toggle value is still coming back asfalse
even after userId update in the context. This is causing issues.