oxc-project/oxc · error · OxcDiagnostic
Context definition is missing display name.
Error message
Context definition is missing display name.
What it means
Raised by react/display-name when a React context created via React.createContext is assigned without a displayName property. Contexts lack an inferred name, making them hard to identify in React DevTools.
Source
Thrown at crates/oxc_linter/src/rules/react/display_name.rs:36
use crate::{
ast_util::iter_outer_expressions,
config::ReactVersion,
context::LintContext,
rule::{DefaultRuleConfig, Rule},
utils::{
InnermostFunction, arrow_function_returns, expression_returns,
find_innermost_function_with_jsx, function_returns, is_hoc_call, is_react_component_name,
},
};
fn component_display_name_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Component definition is missing display name.")
.with_help("Add a `displayName` property to the component.")
.with_label(span)
}
fn context_display_name_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Context definition is missing display name.")
.with_help("Add a `displayName` property to the context.")
.with_label(span)
}
declare_oxc_lint!(
/// ### What it does
///
/// Enforces that React components have a `displayName` property.
///
/// ### Why is this bad?
///
/// React DevTools uses `displayName` to show component names in the component tree.
/// Without `displayName`, components will show up as "Unknown" in DevTools.
///
/// ### Examples
///
/// Examples of **incorrect** code for this rule:
/// ```jsxView on GitHub (pinned to e1e7af627c)
Solutions
- Set MyContext.displayName = "MyContext" after creation.
- Assign the context to a named variable so DevTools can infer the name, or add the displayName property.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/react/display_name.rs:36 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/c5bcc0ff86daa14e.
Report an issue: GitHub.