{"record":{"id":"1b0f3f95f6923b73","repo":"oxc-project/oxc","slug":"fast-refresh-can-t-handle-anonymous-components-ad","errorCode":null,"errorMessage":"Fast refresh can't handle anonymous components. Add a name to your export.","messagePattern":"Fast refresh can't handle anonymous components\\. Add a name to your export\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/react/only_export_components.rs","lineNumber":27,"sourceCode":"\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)\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)","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/react/only_export_components.rs#L9-L45","documentation":"Raised by react/only_export_components when an exported value is an anonymous component — a function without a usable name (e.g. `export default () => <div/>` or an unnamed function expression). At the throw site Fast Refresh relies on component names to match and re-render the right component between edits; with no name it cannot reconcile the module, forcing a full reload. anonymous_components_diagnostic fires from analyze_exports/analyze_export_declaration when the exported declaration's binding name cannot be resolved to a named React component.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/react/only_export_components.rs:27 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Give the component a name: export default function MyComponent() {}.","Assign the anonymous component to a named variable before exporting."],"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"}