{"record":{"id":"42eef319447fbd97","repo":"oxc-project/oxc","slug":"react-hook-hook-name-has-unnecessary-dependency","errorCode":null,"errorMessage":"React Hook {hook_name} has unnecessary dependency: {dep_name}","messagePattern":"React Hook (.+?) has unnecessary dependency: (.+?)","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/react/exhaustive_deps.rs","lineNumber":125,"sourceCode":"    } else {\n        format!(\"React Hook {hook_name} has missing dependencies: {deps_pretty}\")\n    };\n\n    if let Some(dep) = mutable_ref_dependency {\n        let _ = write!(\n            message,\n            \". Mutable values like '{dep}' aren't valid dependencies because mutating them doesn't re-render the component.\"\n        );\n    }\n\n    OxcDiagnostic::warn(message)\n        .with_labels(labels)\n        .with_help(\"Either include it or remove the dependency array.\")\n        .with_error_code_scope(SCOPE)\n}\n\nfn unnecessary_dependency_diagnostic(hook_name: &str, dep_name: &str, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"React Hook {hook_name} has unnecessary dependency: {dep_name}\"))\n        .with_label(span)\n        .with_help(\"Either include it or remove the dependency array.\")\n        .with_error_code_scope(SCOPE)\n}\n\nfn dependency_array_not_array_literal_diagnostic(hook_name: &str, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\n        \"React Hook {hook_name} was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies.\"\n    ))\n    .with_label(span)\n    .with_help(\"Use an array literal as the second argument.\")\n    .with_error_code_scope(SCOPE)\n}\n\nfn literal_in_dependency_array_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"The literal is not a valid dependency because it never changes.\")\n        .with_label(span)\n        .with_help(\"Remove the literal from the array.\")","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/oxc-project/oxc/blob/1f902a69625cd14e6d8dc58feca94da099d2d251/crates/oxc_linter/src/rules/react/exhaustive_deps.rs#L107-L143","documentation":"Raised by react/exhaustive_deps when the dependency array contains a value that is never referenced inside the hook callback. At the throw site the listed dependency causes the effect/callback/memo to be invalidated (re-run or recompute) needlessly on changes to that value, since it is not actually used. run() compares each declared dependency against the values the callback references and reports the superfluous ones, advising either including its usage or removing it from the array.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/react/exhaustive_deps.rs:130 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the unused value from the dependency array.","Use the value inside the callback if it was omitted by mistake."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"1f902a69625cd14e6d8dc58feca94da099d2d251","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}