feature-flags
Manage React feature flags across channels, gate tests conditionally, and debug flag-specific test failures.
- Four flag files control defaults and channel-specific overrides (canary, www, React Native, test renderer) with
__VARIANT__flags simulating gatekeepers tested in both states - Use
@gate flagNamepragma to skip tests entirely when a flag is unavailable, or inlinegate()to branch assertions when behavior differs - Adding a new flag requires entries in the main file plus all fork files; set to
__VARIANT__in www/native-fb forks if the flag should vary by channel - Common pitfalls include forgetting to test both
__VARIANT__states, using@gatefor behavior differences instead of inlinegate(), and omitting fork file entries
React Feature Flags
Flag Files
| File | Purpose |
|---|---|
packages/shared/ReactFeatureFlags.js |
Default flags (canary), __EXPERIMENTAL__ overrides |
packages/shared/forks/ReactFeatureFlags.www.js |
www channel, __VARIANT__ overrides |
packages/shared/forks/ReactFeatureFlags.native-fb.js |
React Native, __VARIANT__ overrides |
packages/shared/forks/ReactFeatureFlags.test-renderer.js |
Test renderer |
Gating Tests
@gate pragma (test-level)
Use when the feature is completely unavailable without the flag:
// @gate enableViewTransition
More from facebook/react
fix
Use when you have lint errors, formatting issues, or before committing code to ensure it passes CI.
1.7Kextract-errors
Use when adding new error messages to React, or seeing "unknown error code" warnings.
958verify
Use when you want to validate changes before committing, or when you need to check all React contribution requirements.
886test
Use when you need to run tests for React core. Supports source, www, stable, and experimental channels.
883flow
Use when you need to run Flow type checking, or when seeing Flow type errors in React code.
826flags
Use when you need to check feature flag states, compare channels, or debug why a feature behaves differently across release channels.
783