oxc-project/oxc · error · OxcDiagnostic
Fast refresh only works when a file has exports. Move your c
Error message
Fast refresh only works when a file has exports. Move your component(s) to a separate file.
What it means
Raised by react/only_export_components when the file defines component(s) but has no export statements at all. At the throw site the components are module-local, which is fine for Fast Refresh itself, but the rule flags the file because the author most likely intended to export the component and forgot — and once exported alone it will be refreshable. no_export_diagnostic is produced from report_diagnostics when analyze_exports found components yet zero exports.
Source
Thrown at crates/oxc_linter/src/rules/react/only_export_components.rs:39
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;
fn deref(&self) -> &Self::Target {
&self.0
}
}View on GitHub (pinned to e1e7af627c)
Solutions
- Export the component(s) from the file.
- Move the component(s) to a file where they are exported.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/react/only_export_components.rs:39 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/1cf832745d6be622.
Report an issue: GitHub.