{"record":{"id":"b864a31114dfcd20","repo":"oxc-project/oxc","slug":"using-this-refs-is-deprecated","errorCode":null,"errorMessage":"Using this.refs is deprecated.","messagePattern":"Using this\\.refs is deprecated\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/react/no_string_refs.rs","lineNumber":22,"sourceCode":"        Expression, JSXAttribute, JSXAttributeName, JSXAttributeValue, JSXExpression,\n        JSXExpressionContainer,\n    },\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\nuse schemars::JsonSchema;\nuse serde::Deserialize;\n\nuse crate::{\n    AstNode,\n    context::{ContextHost, LintContext},\n    rule::{DefaultRuleConfig, Rule},\n    utils::get_parent_component,\n};\n\nfn this_refs_deprecated(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Using this.refs is deprecated.\")\n        .with_help(\"Using this.xxx instead of this.refs.xxx\")\n        .with_label(span)\n}\n\nfn string_in_ref_deprecated(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Using string literals in ref attributes is deprecated.\")\n        .with_help(\"Using reference callback instead\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone, JsonSchema, Deserialize)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\npub struct NoStringRefs {\n    /// Disallow template literals in addition to string literals.\n    no_template_literals: bool,\n}\n\ndeclare_oxc_lint!(","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/react/no_string_refs.rs#L4-L40","documentation":"Raised by react/no_string_refs when code accesses `this.refs` (a member expression on `refs` of `this`). At the throw site the component uses the legacy refs API removed in React 16 — `this.refs` only returns the DOM node, not the component, and no longer works — so the code is broken or relying on ancient behavior. run() reports member accesses on this.refs via this_refs_deprecated.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/react/no_string_refs.rs:22 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use React.createRef() or callback refs instead of this.refs.","Access members directly rather than through this.refs.xxx."],"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"}