Open romulof opened 7 months ago
Thank you for your submission. We will discuss this internally and provide an update soon. Logged internally as 226042.
🤔 Just curious, can't you do something like this?
const LDProvider = lazy(async () => ({ default: await asyncWithLDProvider(config) }));
return (
<Suspense>
<LDProvider>{children}</LDProvider>
</Suspense>
);
Anything I should be worried about with this workaround?
Is your feature request related to a problem? Please describe.
Current initialisation is done by HOC and/or functions what generate the provider component for you. In some setups this can be troublesome to use, for example when you don't have much control over you app initialisation.
Describe the solution you'd like
Would be amazing if we could just use
<LDProvider>
and until it is ready, it will trigger React suspense mode. This is easily achieved by throwing a promise object. This object is caught by<Suspense>
and it renders afallback
(aka loading component) until this promise resolves.Describe alternatives you've considered
There are definitely other alternatives, but not as simple and supported by React itself.
Additional context
N/A