Find: Multiple Root Elements
Find the Mistake Easy
Question
What is wrong with this component?
Code
function Header() {
return (
<h1>Title</h1>
<p>Subtitle</p>
);
}
Hint
A component can only return one root element.
Explanation
The component returns two sibling elements without a wrapper. React requires a single root element. The fix is to wrap them in a Fragment: return (<><h1>Title</h1><p>Subtitle</p></>);.
Related Resources
Related Lessons
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.