{"record":{"id":"12f094a81b3bbc92","repo":"oxc-project/oxc","slug":"components-wrapped-with-forwardref-must-have-a","errorCode":null,"errorMessage":"Components wrapped with `forwardRef` must have a `ref` parameter","messagePattern":"Components wrapped with `forwardRef` must have a `ref` parameter","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/react/forward_ref_uses_ref.rs","lineNumber":14,"sourceCode":"use oxc_ast::{\n    AstKind,\n    ast::{CallExpression, Expression},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{\n    AstNode, ast_util::outermost_paren_parent, context::LintContext, fixer::RuleFixer, rule::Rule,\n};\n\nfn forward_ref_uses_ref_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Components wrapped with `forwardRef` must have a `ref` parameter\")\n        .with_help(\"Add a `ref` parameter, or remove `forwardRef`\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct ForwardRefUsesRef;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Requires that components wrapped with `forwardRef` must have a `ref` parameter.\n    /// Omitting the `ref` argument is usually a bug,\n    /// and components not using `ref` don't need to be wrapped by `forwardRef`.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// Omitting the `ref` argument makes the `forwardRef` wrapper unnecessary,\n    /// and can lead to confusion.","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/react/forward_ref_uses_ref.rs#L1-L32","documentation":"Raised by react/forward-ref-uses-ref when a component wrapped in React.forwardRef does not declare a ref parameter in its render function. The forwarded ref is silently dropped and never reaches the DOM node.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/react/forward_ref_uses_ref.rs:14 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add the ref parameter: forwardRef((props, ref) => ...) and attach it to the rendered element.","Remove forwardRef if the component does not need to expose a ref."],"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"}