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
I'm using useFeature hook to get the feature flag and later use react query to call diff endpoint per feature flag setting.
When the component renders, I get isEnabled returned from the hook as false but later on all true. The setting on the Optimizely end for the flag is true and I can see it from the returned datafile as well.
I also tried to use clientReady, but it was true ever since component rendered.
Is this the default behaviour? I'm expecting isEnabled to be undefined while the client sdk is processing the datafile to get the isEnabled state.
Thanks,
Expected Behavior
useFeature hook should return undefined while processing
Steps To Reproduce
just use useFeature hook for a specific feature
React Framework
"react": "^18.3.1",
Browsers impacted
No response
Link
No response
Logs
No response
Severity
No response
Workaround/Solution
No response
Recent Change
No response
Conflicts
No response
The text was updated successfully, but these errors were encountered:
clientReady should not be ready from the beginning. And we made some changes regarding that. [FSSDK-10730] isClientReady logic adjustment #285. v3.2.3 contains the change. You are one patch short from that.
useFeature is designed this way from the beginning. If the client is not ready, it returns false as a default. I can understand why that could be misleading. So Your proposal on using undefined instead of false might be a better idea. But I don't see it as a bug necessarily. It could be an enhancement request. I have created an internal ticket FSSDK-11245 to track this.
@junaed-optimizely Thanks for the reply. I'm using ^3.2.2 so I think I'm actually using v3.2.3? but still clientReady is instantly true when component renders while isEnabled is false and in the datafile it's true.
So it sounds like getting isEnabled as false initially from useFeature is by design? In our case, we actually want three states for isEnabled i.e undefined when client is not ready, true and false when it is. Is there an existing workaround where we know when the client is not ready? clientReady doesn't seem to work. Currently, we just wait for a sec before reading isEnabled.
Is there an existing issue for this?
SDK Version
"@optimizely/react-sdk": "^3.2.2",
Current Behavior
I'm using
useFeature
hook to get the feature flag and later use react query to call diff endpoint per feature flag setting.When the component renders, I get
isEnabled
returned from the hook as false but later on all true. The setting on the Optimizely end for the flag is true and I can see it from the returned datafile as well.I also tried to use
clientReady
, but it was true ever since component rendered.Is this the default behaviour? I'm expecting
isEnabled
to beundefined
while the client sdk is processing the datafile to get theisEnabled
state.Thanks,
Expected Behavior
useFeature
hook should returnundefined
while processingSteps To Reproduce
just use
useFeature
hook for a specific featureReact Framework
Browsers impacted
No response
Link
No response
Logs
No response
Severity
No response
Workaround/Solution
No response
Recent Change
No response
Conflicts
No response
The text was updated successfully, but these errors were encountered: