Using `useFlags` outside of the `LDProvider` context does not raise an error
Take the following example code (highly simplified):
const flags = useFlags()
return <LDProvider>{children}</LDProvider>
The call to useFlags occurs outside of the LDProvider context, thus resulting in an empty flags object {}. However, this does not raise some warning/error in the console, which would be helpful for catching this in less obvious cases.
Thank you for reporting this. We will investigate and provide an update soon. Internally logged as 213181.
Thanks @yusinto!
We could try catch the react error dispatcher is null but we follow the react's team design to let the application do this. You can easily wrap a try catch in your application this way if you choose to:
try {
const flags = useFlags();
} catch(e) {
console.log(`Provider not setup: ${e}`)
}
This issue is marked as stale because it has been open for 30 days without activity. Remove the stale label or comment, or this will be closed in 7 days.
Hi, is this issue still opened to work upon or is it closed? Thanks.