Configuration
React Compiler provides extensive configuration options to customize its behavior for your project.Basic Configuration
babel.config.js
Memoization Options
enablePreserveExistingMemoizationGuarantees
Type:booleanDefault:
true
Preserves guarantees about when values are memoized from existing useMemo/useCallback calls.
true:
- Compiler uses
useMemo/useCallbackboundaries to understand mutation points - Guarantees existing referential equality behavior is preserved
- Preserves effect execution patterns that depend on referential equality
false:
- Compiler ignores manual memoization completely
- May change effect execution frequency
- Mimics removing all manual memoization
validatePreserveExistingMemoizationGuarantees
Type:booleanDefault:
true
Validates that all useMemo/useCallback values are also memoized by the compiler.
enablePreserveExistingManualUseMemo
Type:booleanDefault:
false
When true, keeps existing useMemo/useCallback calls instead of pruning them.
Validation Options
validateHooksUsage
Type:booleanDefault:
true
Validates that the component follows the Rules of Hooks.
- Conditional hook calls
- Hook calls in loops
- Hook calls in nested functions
validateRefAccessDuringRender
Type:booleanDefault:
true
Validates that ref.current is not accessed during render.
validateNoSetStateInRender
Type:booleanDefault:
true
Validates that setState is not called unconditionally during render.
validateNoSetStateInEffects
Type:booleanDefault:
false
Validates that setState is not called synchronously within effects.
validateExhaustiveMemoizationDependencies
Type:booleanDefault:
true
Validates that dependencies in manual memoization are exhaustive.
validateExhaustiveEffectDependencies
Type:'off' | 'all' | 'missing-only' | 'extra-only'Default:
'off'
Validates effect hook dependencies.
'off': No validation'all': Report missing and extra dependencies'missing-only': Only report missing dependencies'extra-only': Only report unnecessary dependencies
validateMemoizedEffectDependencies
Type:booleanDefault:
false
Validates that effect dependencies are memoized to prevent infinite renders.
validateNoDerivedComputationsInEffects
Type:booleanDefault:
false
Validates that effects don’t calculate derived data that could be computed during render.
validateNoCapitalizedCalls
Type:string[] | nullDefault:
null
Validates against calling capitalized functions (potential components with hooks).
Optimization Features
enableOptionalDependencies
Type:booleanDefault:
true
Infers optional chaining in dependencies.
lowerContextAccess
Type:booleanDefault:
false
Optimizes context access with selectors.
enableJsxOutlining
Type:booleanDefault:
false
Extracts static JSX into separate components.
enableFunctionOutlining
Type:booleanDefault:
false
Outlines pure functions for better memoization.
Type System Options
enableUseTypeAnnotations
Type:booleanDefault:
false
Trusts user-supplied type annotations for better inference.
flowTypeProvider
Type:function | nullDefault:
null
Provides Flow type information to the compiler.
moduleTypeProvider
Type:function | nullDefault:
null
Provides module type signatures for imports.
Custom Hooks and Macros
customHooks
Type:Map<string, Hook>Default:
new Map()
Defines custom hook signatures.
customMacros
Type:string[] | nullDefault:
null
Lists macro function names that should not be transformed.
Development Options
enableResetCacheOnSourceFileChanges
Type:boolean | nullDefault:
null
Enables HMR support by resetting cache when source changes.
enableEmitFreeze
Type:ExternalFunction | nullDefault:
null
Wraps memoized values in dev-mode mutation detector.
validateSourceLocations
Type:booleanDefault:
false
Validates that generated AST has proper source locations.
Advanced Options
enableAssumeHooksFollowRulesOfReact
Type:booleanDefault:
true
Assumes hooks follow React’s rules (freeze arguments and return values).
enableTransitivelyFreezeFunctionExpressions
Type:booleanDefault:
true
Assumes values captured by functions passed to React are not subsequently modified.
inferEffectDependencies
Type:Array<{function: ExternalFunction, autodepsIndex: number}> | nullDefault:
null
Auto-infers and inserts effect dependencies.
inlineJsxTransform
Type:{elementSymbol: string, globalDevVar: string} | nullDefault:
null
Inlines JSX as object literals instead of using JSX runtime.
Complete Example
babel.config.js
Environment-Specific Configuration
Next Steps
Babel Plugin
Advanced Babel integration
ESLint Plugin
Configure linting rules
How It Works
Understand compiler behavior
Architecture
Deep dive into compilation