Closed hon2a closed 1 year ago
I think changing the documentation would be the right move, at least in the current major version. Even though the current behavior is confusing, changing it now would be a breaking change for anyone who was relying on it (and I don't think we could just call it a bug to be fixed in a patch version, because the current behavior isn't an arbitrary mistake in an implementation detail, it is logical in terms of those being the actual flag keys that exist by LD; it's just not documented correctly).
This has been documented here: https://docs.launchdarkly.com/sdk/client-side/react/react-web#configuring-the-react-sdk
The flag keys must be in their original form as known to LaunchDarkly rather than in their camel-cased form.
This is indeed working as designed, they are supposed to be the flag keys as created in LD. They can be any casing FWIW, they don't have to be kebab case.
I see it's not explained in the SDK's API docs though, I'll see what I can do about that 👍
Those docs were updated, hopefully it's a bit more clear now.
Thanks, looks quite clear to me.
When initializing LaunchDarkly with
asyncWithLDProvider
it's possible to addflags
as part of the config. The result is twofold:However, it turns out that while the React SDK transforms the flags to kebab-case by default (e.g. output from
useFlags
), it still expects theflags
in initialization config to be snake-cased. This was unexpected for me and took me quite a while to figure out, so I'd suggest that one of the following might help future users. Eitherflags
in config to be camel-cased whileuseCamelCaseFlagKeys
istrue
(default), orThanks for your time.