react-client-sdk
react-client-sdk copied to clipboard
LDProvider should use the latest flags when it is mounted
Describe the bug
The LDProvider returned by asyncWithLDProvider keeps using the initial flags on mount even though the flags are updated.
To reproduce
- Call
asyncWithLDProviderand it gets initial flags for example{} - Mount the
LDProviderand callidentifyto update the flag to something like{flag1: { value: true}} - The
ldClientkeeps the latest flags{flag1: { value: true}}on memory. But theLDProviderclosure keeps the initial flags{}4. When we re-mount theLDProviderfor some reason, it uses the initial flags for the initial value of the context. - Call the
identifyagain to get the latest flags. The{flag1: { value: true}}is fetched, but theldClientsays "The flags are the same as the current one, so I don't emit the change event". - And the provider keeps the
{}flags as its context.
Expected behavior
LDProvider should use the latest flags, which are the same as the ldClient keeps.
Additional context
I will send a pull request to explain the issue :)
We are investigating this internally as #234809.