flopflip
flopflip copied to clipboard
Default flags are ignored during the first render
Describe the bug
Flags are evaluated as false
during the first render even if default flags are provided.
To Reproduce Steps to reproduce the behavior:
- Clone https://github.com/taschetto/flopflip-bug
-
yarn && yarn start
- Open the console DevTools in your preferred browser
- Notice that the first render outputs
false
for all feature flags, even though the defaults are different - Then, eventually, the flags assume the default value
Expected behavior Any tentative to evaluate flags should read from the default flags even during the first render.
Screenshots
Hi, thanks for reporting the issue. Personally I've not perceived this as an issue so far but that depends on the case. Have you had a look around the library to gauge how to possibly fix it?
I consider this an inconvenience, especially for non-boolean feature flags. For example, that particular flag dashboardColor
has many variants that return a hex color. If I try to use the variant as-is in CSS properties, I'll have an invalid value during a few renders. Of course, this can be circumvented in the consumer with some explicit defaults/fallbacks, but it begins to be a hassle once your consumers grow in complexity or number. This can be a problem while writing unit tests as well since the first render will not include the valid flags, and we need to introduce some mechanism to wait for it to be in the correct state.
Yes, I read the documentation, but so far, I couldn't find a solution.