oxc-project/oxc · error · OxcDiagnostic
This dependency is specified more than once in the dependenc
Error message
This dependency is specified more than once in the dependency array.
What it means
Raised by react/exhaustive_deps when the same dependency appears more than once in a hook's dependency array. At the throw site the duplicate entry is redundant — React only reads it once — and it usually signals a copy/paste mistake or an oversight when editing the list. run() detects repeated identifiers within a single dependency array literal and reports the duplicated element span.
Source
Thrown at crates/oxc_linter/src/rules/react/exhaustive_deps.rs:153
fn dependency_array_not_array_literal_diagnostic(hook_name: &str, span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn(format!(
"React Hook {hook_name} was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies."
))
.with_label(span)
.with_help("Use an array literal as the second argument.")
.with_error_code_scope(SCOPE)
}
fn literal_in_dependency_array_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("The literal is not a valid dependency because it never changes.")
.with_label(span)
.with_help("Remove the literal from the array.")
.with_error_code_scope(SCOPE)
}
fn duplicate_dependency_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("This dependency is specified more than once in the dependency array.")
.with_label(span)
.with_help("Remove the duplicate dependency from the array.")
.with_error_code_scope(SCOPE)
}
fn complex_expression_in_dependency_array_diagnostic(hook_name: &str, span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn(format!(
"React Hook {hook_name} has a complex expression in the dependency array.",
))
.with_label(span)
.with_help("Extract the expression to a separate variable so it can be statically checked.")
.with_error_code_scope(SCOPE)
}
fn dependency_changes_on_every_render_diagnostic(
hook_name: &str,
span: Span,
dep_name: &str,View on GitHub (pinned to e1e7af627c)
Solutions
- Remove duplicate entries so each dependency appears exactly once.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/react/exhaustive_deps.rs:153 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/bd7be15cf8722696.
Report an issue: GitHub.