{"record":{"id":"f78075c516196009","repo":"oxc-project/oxc","slug":"react-hook-hook-name-has-a-complex-expression-in","errorCode":null,"errorMessage":"React Hook {hook_name} has a complex expression in the dependency array.","messagePattern":"React Hook (.+?) has a complex expression in the dependency array\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/react/exhaustive_deps.rs","lineNumber":160,"sourceCode":"    .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.\")\n        .with_error_code_scope(SCOPE)\n}\n\nfn duplicate_dependency_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"This dependency is specified more than once in the dependency array.\")\n        .with_label(span)\n        .with_help(\"Remove the duplicate dependency from the array.\")\n        .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\"),","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/react/exhaustive_deps.rs#L142-L178","documentation":"Raised by react/exhaustive-deps when the dependency array contains a complex expression (function call, computed member access, chained logic) rather than a simple identifier. The linter cannot statically analyze its reactivity.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/react/exhaustive_deps.rs:160 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Extract the expression into a variable (often memoized with useMemo) and depend on that variable.","Simplify the expression to a plain identifier or property access."],"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"}