{"record":{"id":"c7b3f6d83c96286c","repo":"oxc-project/oxc","slug":"fast-refresh-only-works-when-a-file-only-exports-c","errorCode":null,"errorMessage":"Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components.","messagePattern":"Fast refresh only works when a file only exports components\\. Use a new file to share constants or functions between components\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/react/only_export_components.rs","lineNumber":22,"sourceCode":"use oxc_semantic::NodeId;\nuse oxc_span::{GetSpan, Span};\nuse rustc_hash::FxHashSet;\nuse schemars::JsonSchema;\nuse serde::{Deserialize, Serialize};\n\nuse crate::{\n    context::LintContext,\n    rule::{DefaultRuleConfig, Rule},\n    utils::is_react_component_name,\n};\n\nfn 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)","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/react/only_export_components.rs#L4-L40","documentation":"Raised by react/only-export-components when a file exports both components and non-component values (constants, functions). React Fast Refresh only preserves state when a file exports components exclusively.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/react/only_export_components.rs:22 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Move shared constants/functions to a separate module file.","Keep only component exports in the component file."],"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-14T00:17:10.932Z"}