oxc-project/oxc · error · OxcDiagnostic

React Hook {hook_name} does nothing when called with only on

Error message

React Hook {hook_name} does nothing when called with only one argument.

What it means

Raised by react/exhaustive_deps when a React hook that requires a dependency array (useEffect/useCallback/useMemo etc.) is called with only one argument and no second argument at all. Unlike the 'requires an effect callback' case, the callback exists but the dependency list was omitted entirely, so the rule cannot statically verify dependency correctness and the effect may re-run every render (or never update closed-over values as the author intends). run() reports this per hook call site missing its second argument.

Source

Thrown at crates/oxc_linter/src/rules/react/exhaustive_deps.rs:52

    ast_util::{
        get_declaration_from_reference_id, get_declaration_of_variable, get_enclosing_function,
    },
    context::LintContext,
    rule::{DefaultRuleConfig, Rule},
    utils::deserialize_regex_option,
};

const SCOPE: &str = "react-hooks";

fn missing_callback_diagnostic(hook_name: &str, span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn(format!("React hook {hook_name} requires an effect callback."))
        .with_label(span)
        .with_help("Did you forget to pass a callback to the hook?")
        .with_error_code_scope(SCOPE)
}

fn dependency_array_required_diagnostic(hook_name: &str, span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn(format!(
        "React Hook {hook_name} does nothing when called with only one argument."
    ))
    .with_label(span)
    .with_help("Did you forget to pass an array of dependencies?")
    .with_error_code_scope(SCOPE)
}

fn unknown_dependencies_diagnostic(hook_name: &str, span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn(format!(
        "React Hook {hook_name} received a function whose dependencies are unknown."
    ))
    .with_help("Pass an inline function instead.")
    .with_label(span)
    .with_error_code_scope(SCOPE)
}

fn async_effect_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Effect callbacks are synchronous to prevent race conditions.")

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Add a dependency array as the second argument, e.g. useMemo(() => ..., [deps]).
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/react/exhaustive_deps.rs:52 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/b2e1556eaae956c6. Report an issue: GitHub.