[FEATURE] React SDK: Provide hook to set relevant context "useContextMutator
"
#968
Labels
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
Background
The
OpenFeatureProvider
React context provider binds an OpenFeature client to a React Context. Components within that boundary use the associated client for evaluations, etc. The client can be associated with a domain (see https://github.com/open-feature/js-sdk/blob/main/packages/react/README.md#multiple-providers-and-domains and https://github.com/open-feature/js-sdk/blob/main/packages/client/README.md#domains)We do not currently have a hook that makes it easy to update this context. It's necessary to use the global object to do this. We should add a hook that allows the correct context for the enclosed scope to be set.
For example, this current implementation:
Could be instead be:
This would make things easier for users, and fit better into react idioms. Please test your solution but using it in the sample react app here.
Requirements
Additional Considerations
I'd love to see considerations from the implementor on the following:
setContext
,mergeContext
etc, which merge the context?The text was updated successfully, but these errors were encountered: