{"record":{"id":"2b9f4ffb2fe4c69e","repo":"oxc-project/oxc","slug":"react-hook-hook-name-has-a-missing-dependency","errorCode":null,"errorMessage":"React Hook {hook_name} has a missing dependency: {deps_pretty}","messagePattern":"React Hook (.+?) has a missing dependency: (.+?)","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/react/exhaustive_deps.rs","lineNumber":118,"sourceCode":"                dep.span.into()\n            }\n        })\n        .chain(std::iter::once(span.primary()));\n\n    let mut message = if single {\n        format!(\"React Hook {hook_name} has a missing dependency: {deps_pretty}\")\n    } 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.\")","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/oxc-project/oxc/blob/1f902a69625cd14e6d8dc58feca94da099d2d251/crates/oxc_linter/src/rules/react/exhaustive_deps.rs#L100-L136","documentation":"Raised by react/exhaustive-deps when a value used inside a hook callback is not listed in its dependency array (single missing dependency). Omitted dependencies cause stale closures and bugs when the value changes.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/react/exhaustive_deps.rs:123 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add the listed value to the dependency array.","If the value should not retrigger the hook, memoize it with useRef/useCallback/useMemo.","Move the value inside the callback if it does not need to be reactive."],"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"}