oxc-project/oxc · error · OxcDiagnostic
Fast refresh only works when a file only exports components.
Error message
Fast refresh only works when a file only exports components. Move your component(s) to a separate file.
What it means
Raised by react/only_export_components when a file exports both component(s) and non-component values (constants, functions, utilities). At the throw site Fast Refresh only works for modules whose exports are all components; mixed exports make the boundary un-refreshable and edits trigger full reloads, losing state. local_components_diagnostic is emitted from report_diagnostics for the offending non-component export(s) in a mixed module.
Source
Thrown at crates/oxc_linter/src/rules/react/only_export_components.rs:34
fn export_all_components_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("This rule can't verify that `export *` only exports components.")
.with_label(span)
}
fn named_export_components_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components.")
.with_label(span)
}
fn anonymous_components_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn(
"Fast refresh can't handle anonymous components. Add a name to your export.",
)
.with_label(span)
}
fn local_components_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Fast refresh only works when a file only exports components. Move your component(s) to a separate file.")
.with_label(span)
}
fn no_export_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Fast refresh only works when a file has exports. Move your component(s) to a separate file.")
.with_label(span)
}
fn react_context_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Fast refresh only works when a file only exports components. Move your React context(s) to a separate file.")
.with_label(span)
}
#[derive(Debug, Default, Clone, Deserialize)]
pub struct OnlyExportComponents(Box<OnlyExportComponentsConfig>);
impl std::ops::Deref for OnlyExportComponents {
type Target = OnlyExportComponentsConfig;View on GitHub (pinned to e1e7af627c)
Solutions
- Move the component(s) into a dedicated file that exports only components.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/react/only_export_components.rs:34 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/e3377e0bf965cb43.
Report an issue: GitHub.