{"record":{"id":"c3507d07cd8667c4","repo":"oxc-project/oxc","slug":"react-hook-hook-name-depends-on-dep-name-wh","errorCode":null,"errorMessage":"React hook {hook_name} depends on `{dep_name}`, which changes every render","messagePattern":"React hook (.+?) depends on `(.+?)`, which changes every render","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/react/exhaustive_deps.rs","lineNumber":174,"sourceCode":"        .with_error_code_scope(SCOPE)\n}\n\nfn complex_expression_in_dependency_array_diagnostic(hook_name: &str, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\n        \"React Hook {hook_name} has a complex expression in the dependency array.\",\n    ))\n    .with_label(span)\n    .with_help(\"Extract the expression to a separate variable so it can be statically checked.\")\n    .with_error_code_scope(SCOPE)\n}\n\nfn dependency_changes_on_every_render_diagnostic(\n    hook_name: &str,\n    span: Span,\n    dep_name: &str,\n    dep_decl_span: Span,\n) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\n        \"React hook {hook_name} depends on `{dep_name}`, which changes every render\"\n    ))\n    .with_labels([\n        span.primary_label(\"it will always cause this hook to re-evaluate\"),\n        dep_decl_span.label(format!(\"`{dep_name}` is declared here\")),\n    ])\n    .with_help(\"Try memoizing this variable with `useRef` or `useCallback`.\")\n    .with_error_code_scope(SCOPE)\n}\n\nfn unnecessary_outer_scope_dependency_diagnostic(\n    hook_name: &str,\n    dep_name: &str,\n    span: Span,\n) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\n        \"React Hook {hook_name} has an unnecessary dependency: {dep_name}.\"\n    ))","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/react/exhaustive_deps.rs#L156-L192","documentation":"Raised by react/exhaustive-deps when a dependency is an object/array/function recreated on every render (e.g. an inline object literal or unmemoized callback). The hook re-runs every render, defeating memoization.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/react/exhaustive_deps.rs:174 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Wrap the value in useMemo or useCallback so its identity is stable.","Store mutable values in a ref and read ref.current inside the hook.","Move the declaration outside the component if it is constant."],"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"}