- Notifications
You must be signed in to change notification settings - Fork 37
Closed
Labels
Description
Is there an existing issue for this?
- I have searched the existing issues
SDK Version
3.0.0
Current Behavior
When attempting to set the user ID on the Optimizely ReactSDK client using setUser()
I see the following error when implementing a feature flag:
Unable to determine if feature "<feature key>" is enabled because User ID is not set
Expected Behavior
Setting a user ID using setUser()
should set the usr ID on the client.
Steps To Reproduce
import { createInstance, OptimizelyProvider } from "@optimizely/react-sdk"; const App = () => { const optimizelyClient = createInstance({ sdkKey: "<key>", }); optimizelyClient.setUser({ id: "12345" }); return ( <OptimizelyProvider optimizely={optimizelyClient}> <Children /> </OptimizelyProvider> ); }
...then, in a child component:
const [isEnabled] = useFeature("<feature key>");
React Framework
React 18.2.0 (Create React App + react-app-rewired)
Browsers impacted
Reproducible in both Chrome and Safari. No other browsers were tested. The issue does not seem to be browser-specific.
Link
No response
Logs
Severity
No response
Workaround/Solution
I'm forced to abandon this approach and have to set the user ID via the user
prop in <OptimizelyProvider>
.
Recent Change
No
Conflicts
No response
daniel-trevino and DoroGi