{"record":{"id":"1cf832745d6be622","repo":"oxc-project/oxc","slug":"fast-refresh-only-works-when-a-file-has-exports-m","errorCode":null,"errorMessage":"Fast refresh only works when a file has exports. Move your component(s) to a separate file.","messagePattern":"Fast refresh only works when a file has exports\\. Move your component\\(s\\) to a separate file\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/react/only_export_components.rs","lineNumber":39,"sourceCode":"fn named_export_components_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components.\")\n        .with_label(span)\n}\n\nfn anonymous_components_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\n        \"Fast refresh can't handle anonymous components. Add a name to your export.\",\n    )\n    .with_label(span)\n}\n\nfn local_components_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Fast refresh only works when a file only exports components. Move your component(s) to a separate file.\")\n        .with_label(span)\n}\n\nfn no_export_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Fast refresh only works when a file has exports. Move your component(s) to a separate file.\")\n        .with_label(span)\n}\n\nfn react_context_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Fast refresh only works when a file only exports components. Move your React context(s) to a separate file.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone, Deserialize)]\npub struct OnlyExportComponents(Box<OnlyExportComponentsConfig>);\n\nimpl std::ops::Deref for OnlyExportComponents {\n    type Target = OnlyExportComponentsConfig;\n\n    fn deref(&self) -> &Self::Target {\n        &self.0\n    }\n}","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/react/only_export_components.rs#L21-L57","documentation":"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.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/react/only_export_components.rs:39 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Export the component(s) from the file.","Move the component(s) to a file where they are exported."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}