Closed mether closed 1 year ago
Hello @mether,
Thank you for the report.
Filed internally as 174659
Thanks, Ryan
I see the problem, our asyncWithLDProvider
is currently setting the initial values in an effect, instead of setting the initial value in the useState
call. As a result they miss the first render. We will work on a fix for that.
Thanks, Ryan
Ahh that makes sense
Cheers for the update Ryan!
@mether This has been fixed in the 2.29.2 release.
Thanks, Ryan
Cheers Ryan, just confirming that the fix worked for me 👍
I'll go ahead and close this ticket, thanks for the speedy resolution!
Is this a support request? This issue tracker is maintained by LaunchDarkly SDK developers and is intended for feedback on the SDK code. If you're not sure whether the problem you are having is specifically related to the SDK, or to the LaunchDarkly service overall, it may be more appropriate to contact the LaunchDarkly support team; they can help to investigate the problem and will consult the SDK team if necessary. You can submit a support request by going here or by emailing support@launchdarkly.com.
Note that issues filed on this issue tracker are publicly accessible. Do not provide any private account information on your issues. If your problem is specific to your account, you should submit a support request as described above.
Describe the bug A clear and concise description of what the bug is.
Hey there!
When using
asyncWithLDProvider
withuseFlags
in a child component, the flags object is empty on the initial render i.e. not initializedTo reproduce Steps to reproduce the behavior.
I reproduced the bug in a codesandbox and compared
useFlags
vsuseLDClient()?.allFlags()
to demonstrate the issuehttps://codesandbox.io/s/heuristic-cache-lu7j72
Steps:
asyncWithLDProvider
at the app entry point and wrap around a componentconst flags = useFlags()
andconsole.log(flags)
I also noticed that if you use
useLDClient()?.allFlags()
it will return the flags on the initial render, which I will likely use as a workaround for nowExpected behavior A clear and concise description of what you expected to happen.
When using
asyncWithLFProvider
I expectuseFlags
to already have the flags availableThis expected behaviour is outlined in the docs:
Logs If applicable, add any log output related to your problem.
See codesandbox and open up the console
SDK version The version of this SDK that you are using.
Latest 2.29.1
Language version, developer tools For instance, Go 1.11 or Ruby 2.5.3. If you are using a language that requires a separate compiler, such as C, please include the name and version of the compiler too.
See codesandbox for dependencies
OS/platform For instance, Ubuntu 16.04, Windows 10, or Android 4.0.3. If your code is running in a browser, please also include the browser type and version.
MacOS 12.6
Additional context Add any other context about the problem here.