oxc-project/oxc · error · OxcDiagnostic
React Hook {hook_name} received a function whose dependencie
Error message
React Hook {hook_name} received a function whose dependencies are unknown. What it means
Raised by react/exhaustive-deps when a hook receives a function whose dependencies cannot be statically determined, such as a function returned from another function or an imported opaque callback. The linter cannot verify the dependency list.
Source
Thrown at crates/oxc_linter/src/rules/react/exhaustive_deps.rs:61
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.")
.with_label(span)
.with_help("Consider putting the asynchronous code inside a function and calling it from the effect.")
.with_error_code_scope(SCOPE)
}
fn missing_dependency_diagnostic(
hook_name: &str,
deps: &[Name<'_>],
span: Span,View on GitHub (pinned to e1e7af627c)
Solutions
- Pass an inline function literal to the hook so its dependencies can be statically checked.
- Move the callback definition into the component or wrap it with useCallback.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/react/exhaustive_deps.rs:61 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/edcd022c9756fbc7.
Report an issue: GitHub.