{"record":{"id":"e3377e0bf965cb43","repo":"oxc-project/oxc","slug":"fast-refresh-only-works-when-a-file-only-exports-c-e3377e","errorCode":null,"errorMessage":"Fast refresh only works when a file only exports components. Move your component(s) to a separate file.","messagePattern":"Fast refresh only works when a file only exports components\\. 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":34,"sourceCode":"fn export_all_components_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"This rule can't verify that `export *` only exports components.\")\n        .with_label(span)\n}\n\nfn 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;","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/react/only_export_components.rs#L16-L52","documentation":"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.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/react/only_export_components.rs:34 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Move the component(s) into a dedicated file that exports only components."],"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"}