flopflip icon indicating copy to clipboard operation
flopflip copied to clipboard

Default flags are ignored during the first render

Open taschetto opened this issue 2 years ago • 2 comments

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:

  1. Clone https://github.com/taschetto/flopflip-bug
  2. yarn && yarn start
  3. Open the console DevTools in your preferred browser
  4. Notice that the first render outputs false for all feature flags, even though the defaults are different
  5. 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

image

taschetto avatar Sep 06 '22 19:09 taschetto

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?

tdeekens avatar Sep 06 '22 20:09 tdeekens

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.

taschetto avatar Sep 07 '22 01:09 taschetto