oxc-project/oxc · error · OxcDiagnostic
Your `render` method should have a `return` statement.
Error message
Your `render` method should have a `return` statement.
What it means
Raised by react/require_render_return when a class component's `render` method lacks a return statement (or has one only on some control-flow paths). At the throw site render must return a React element or null; returning undefined makes React throw 'Nothing was returned from render'. The rule walks the render method's control-flow graph (via oxc_cfg) checking every terminal path, and require_render_return_diagnostic fires from run() when a path terminates without a return instruction carrying a value.
Source
Thrown at crates/oxc_linter/src/rules/react/require_render_return.rs:18
use oxc_ast::{AstKind, ast::Expression};
use oxc_cfg::{
EdgeType, Instruction, InstructionKind, ReturnInstructionKind,
graph::visit::neighbors_filtered_by_edge_weight,
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};
use crate::{
AstNode,
context::{ContextHost, LintContext},
rule::Rule,
utils::{is_es5_component, is_es6_component},
};
fn require_render_return_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Your `render` method should have a `return` statement.")
.with_help("When writing the `render` method in a component it is easy to forget to return the JSX content. This rule will warn if the `return` statement is missing.")
.with_label(span)
}
#[derive(Debug, Default, Clone)]
pub struct RequireRenderReturn;
declare_oxc_lint!(
/// ### What it does
///
/// Require render methods in ES5 and ES2015 React components to return a value.
///
/// This rule is not relevant for function components, and so can potentially be
/// disabled for modern React codebases.
///
/// ### Why is this bad?
///
/// When writing the `render` method in a component it is easy to forget to return theView on GitHub (pinned to e1e7af627c)
Solutions
- Add a return statement covering all branches of the render method.
- Return null when nothing should be rendered.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/react/require_render_return.rs:18 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/8f20754201eab487.
Report an issue: GitHub.