Open
Description
Requirements
This issue has similarities to #968
I am used to seeing the initialization of React providers being very minimal. Some examples are react router and react-query. They require passing in a config and you're done. Internally they could be setting some global state in some core library, but the developer doesn't have to think about that.
With the open-feature react SDK, you need to set the openfeature global object prior to using the provider.
Proposed interface change to the README:
-// Instantiate and set our provider (be sure this only happens once)!
-// Note: there's no need to await its initialization, the React SDK handles re-rendering and suspense for you!
-OpenFeature.setProvider(new InMemoryProvider(flagConfig));
// Enclose your content in the configured provider
function App() {
return (
- <OpenFeatureProvider>
+ <OpenFeatureProvider provider={provider}>
<Page></Page>
</OpenFeatureProvider>
);
}
+//For domain scoped providers
+function App() {
+ return (
+ <OpenFeatureProvider provider={provider} domain={domain}>
+ <Page></Page>
+ </OpenFeatureProvider>
+ );
+}
If we were to do go forward with a change like this, it would probably need to be in the next major release?