facebook avatar

Feature Flags

If you're working on React core and hit a test failure that only happens in the www channel or mysteriously skips in certain environments, this is your troubleshooting guide. It walks you through the fork file system (ReactFeatureFlags.js and its channel-specific variants), explains when to use @gate pragmas versus inline gate() checks, and covers the __VARIANT__ flag behavior that simulates gatekeeper testing. The debugging section on comparing flag states across channels is genuinely useful when you're staring at a CI failure that doesn't reproduce locally. One gotcha worth internalizing: feature flags need to exist in every fork file, not just the main one, which trips people up more than it should.

skills.sh installs
1K
GitHub stars
246.5K
last updated
Jul 14, 2026

Install

$ npx -y skills add facebook/react --skill feature-flags --agent claude-code

Installs into .claude/skills of the current project.

Files

React Feature Flags

Flag Files

FilePurpose
packages/shared/ReactFeatureFlags.jsDefault flags (canary), __EXPERIMENTAL__ overrides
packages/shared/forks/ReactFeatureFlags.www.jswww channel, __VARIANT__ overrides
packages/shared/forks/ReactFeatureFlags.native-fb.jsReact Native, __VARIANT__ overrides
packages/shared/forks/ReactFeatureFlags.test-renderer.jsTest renderer

Gating Tests

@gate pragma (test-level)

Use when the feature is completely unavailable without the flag:

// @gate enableViewTransition
it('supports view transitions', () => {
  // This test only runs when enableViewTransition is true
  // and is SKIPPED (not failed) when false
});

gate() inline (assertion-level)

Use when the feature exists but behavior differs based on flag:

it('renders component', async () => {
  await act(() => root.render(<App />));

  if (gate(flags => flags.enableNewBehavior)) {
    expect(container.textContent).toBe('new output');
  } else {
    expect(container.textContent).toBe('legacy output');
  }
});

Adding a New Flag

Sponsors

Details

Repository
github.com/facebook/react
Category
Frontend Development

More from facebook/react

All 8
1vercel avatarauthoring-skillsvercel/next.jsauthoring skills1Kskills.sh installs
2angular avatarreference-coreangular/angularExplains the mental model and architecture of the code under `packages/core`. You MUST use this skill any time you plan to work with code in `packages/core`992skills.sh installs
3vercel avatarruntime-debugvercel/next.jsruntime debug990skills.sh installs
4facebook avatarflagsfacebook/reactflags942skills.sh installs
5angular avataradev-writing-guideangular/angularComprehensive writing guide for Angular documentation (adev). Covers Google Technical Writing standards, Angular-specific markdown extensions, code blocks, and 914skills.sh installs
6angular avatarreference-compiler-cliangular/angularExplains the mental model and architecture of the code under `packages/compiler-cli`. You MUST use this skill any time you plan to work with code in `packages/c911skills.sh installs