What problem does it solve?
Writing Storybook stories for components gated behind feature flags often fails silently: imperatively calling featureFlagLogic.actions.setFeatureFlags passes in jest but renders the flag-off branch in visual-regression snapshots, producing wrong screenshots while unit tests stay green.
Core Features & Use Cases
- Boolean flags via array form: Set
parameters: { featureFlags: [FEATURE_FLAGS.MY_FLAG] } so flags evaluate to true in every story of the file.
- Multivariate and experiment variants via record form: Pin a specific variant per story, e.g.
featureFlags: { [FEATURE_FLAGS.THEME_OVERRIDE]: 'control' } for one story and 'intent_plus' for another.
- Pitfall guidance: Explains why per-story parameters shallow-merge over meta-level flags (requiring re-listing), and why disabling posthog-js flags breaks the app shell.
- Use Case: You are writing a Storybook story for a React component behind an A/B experiment flag and need both control and treatment arms rendered correctly in visual-regression snapshots.
Quick Start
Add the featureFlags parameter with the needed flag keys or variant values to my Storybook story so the gated component renders the flag-on branch.