{"record":{"id":"60b8a9650b7f465c","repo":"oxc-project/oxc","slug":"react-hook-hook-name-requires-an-effect-callback","errorCode":null,"errorMessage":"React hook {hook_name} requires an effect callback.","messagePattern":"React hook (.+?) requires an effect callback\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/react/exhaustive_deps.rs","lineNumber":45,"sourceCode":"use oxc_span::{GetSpan, Span};\nuse oxc_str::Str;\nuse oxc_syntax::scope::ScopeFlags;\n\nuse crate::{\n    AstNode,\n    ast_util::variable_declaration_kind,\n    ast_util::{\n        get_declaration_from_reference_id, get_declaration_of_variable, get_enclosing_function,\n    },\n    context::LintContext,\n    rule::{DefaultRuleConfig, Rule},\n    utils::deserialize_regex_option,\n};\n\nconst SCOPE: &str = \"react-hooks\";\n\nfn missing_callback_diagnostic(hook_name: &str, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"React hook {hook_name} requires an effect callback.\"))\n        .with_label(span)\n        .with_help(\"Did you forget to pass a callback to the hook?\")\n        .with_error_code_scope(SCOPE)\n}\n\nfn dependency_array_required_diagnostic(hook_name: &str, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\n        \"React Hook {hook_name} does nothing when called with only one argument.\"\n    ))\n    .with_label(span)\n    .with_help(\"Did you forget to pass an array of dependencies?\")\n    .with_error_code_scope(SCOPE)\n}\n\nfn unknown_dependencies_diagnostic(hook_name: &str, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\n        \"React Hook {hook_name} received a function whose dependencies are unknown.\"\n    ))","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/oxc-project/oxc/blob/1f902a69625cd14e6d8dc58feca94da099d2d251/crates/oxc_linter/src/rules/react/exhaustive_deps.rs#L27-L63","documentation":"Raised by react/exhaustive_deps (react-hooks scope) when an effect-style hook such as useEffect or useLayoutEffect is invoked without a callback function as its first argument (e.g. useEffect()). At the throw site the hook call is a no-op: the hook registration is malformed and nothing is scheduled to run after render. run() checks each detected React hook call expression and reports this when the first argument is missing or is not a function.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/react/exhaustive_deps.rs:45 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a callback function as the first argument to the hook, e.g. useEffect(() => {...}, [])."],"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"}