{"record":{"id":"50480a022f296d3e","repo":"oxc-project/oxc","slug":"react-hooks","errorCode":"react-hooks","errorMessage":"Functions returned from `useEffectEvent` must not be included in the dependency array.","messagePattern":"Functions returned from `useEffectEvent` must not be included in the dependency array\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/react/exhaustive_deps.rs","lineNumber":217,"sourceCode":"    OxcDiagnostic::warn(format!(\n        \"React Hook {hook_name} contains a call to setState. Without a list of dependencies, this can lead to an infinite chain of updates.\"\n    ))\n    .with_label(span)\n    .with_help(\"Consider adding an empty list of dependencies to make it clear which values are intended to be stable.\")\n    .with_error_code_scope(SCOPE)\n}\n\nfn ref_accessed_directly_in_effect_cleanup_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"The ref's value `.current` is accessed directly in the effect cleanup function.\")\n        .with_label(span)\n        .with_help(\"The ref value will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by react, copy it to a variable inside the effect and use that variable in the cleanup function.\")\n        .with_error_code_scope(SCOPE)\n}\n\nfn functions_returned_from_use_effect_event_must_not_be_included_in_dependency_array(\n    span: Span,\n) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\n        \"Functions returned from `useEffectEvent` must not be included in the dependency array.\",\n    )\n    .with_label(span)\n    .with_help(\"Remove the dependency from the dependency array.\")\n    .with_error_code_scope(SCOPE)\n}\n\n#[derive(Debug, Default, Clone, Deserialize)]\npub struct ExhaustiveDeps(Box<ExhaustiveDepsConfig>);\n\n#[derive(Debug, Clone, Default, Deserialize, JsonSchema)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\nstruct ExhaustiveDepsConfig {\n    /// Optionally provide a regex of additional hooks to check.\n    #[serde(default, deserialize_with = \"deserialize_additional_hooks\")]\n    additional_hooks: Option<Regex>,\n}\n","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/react/exhaustive_deps.rs#L199-L235","documentation":"Raised by react/exhaustive_deps when a function returned from useEffectEvent is listed in a hook's dependency array. At the throw site the whole point of useEffectEvent is that its returned function is guaranteed stable and must never be a dependency — including it is both unnecessary and explicitly unsupported by React's contract, and can defeat the event function's ability to read latest props/state. run() matches dependency-array identifiers against useEffectEvent declarations and reports the offending entry.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/react/exhaustive_deps.rs:217 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the useEffectEvent-returned function from the dependency array; call it directly inside the hook body."],"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"}