Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using useFlags outside of the LDProvider context does not raise an error #214

Open
davidli3100 opened this issue Aug 15, 2023 · 5 comments

Comments

@davidli3100
Copy link

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.

@yusinto
Copy link
Contributor

yusinto commented Aug 16, 2023

Thank you for reporting this. We will investigate and provide an update soon. Internally logged as 213181.

@davidli3100
Copy link
Author

Thanks @yusinto!

@yusinto
Copy link
Contributor

yusinto commented Sep 11, 2023

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}`)
  }

@yusinto yusinto added the waiting for feedback Indicates LaunchDarkly is waiting for customer feedback before issue is closed due to staleness. label Sep 11, 2023
@github-actions
Copy link

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.

@github-actions github-actions bot added the Stale label Oct 12, 2023
@jaswindersodhi1997
Copy link

Hi, is this issue still opened to work upon or is it closed? Thanks.

@github-actions github-actions bot removed Stale waiting for feedback Indicates LaunchDarkly is waiting for customer feedback before issue is closed due to staleness. labels Oct 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants