Wrap a heading and a paragraph in a single div.
Acceptance criteria
- 1.#root should show Title Body.
React Tutorial · React Introduction
These 10 tasks go with the Your First Component chapter. 5 of them ask you to build something small from scratch; 5 give you code that is already broken and ask you to work out why. Set aside about 90 minutes for the whole set, though you can do them in any order.
Nothing here is marked by a person. When you press Submit, the editor checks your code against the points listed under each task and tells you straight away what passed and what didn't (you need a free account to submit). If you get stuck, there are hints, and a worked solution once you've had a go. The first 2 tasks are free; the rest are part of the practice plan.
If it's been a while since you read the chapter, here is how it starts: “A component is a function that returns UI. There is no base class to extend and no configuration object — if it returns JSX and its name is capitalised, it is a component.” .
1.Return one elementexercise · easy · 10 min
Wrap a heading and a paragraph in a single div.
Passes when: #root should show Title Body.
2.Use a fragmentexercise · easy · 10 min · practice plan
Return two elements without adding a wrapper element.
Passes when: #root should show one two.
3.Return nullexercise · easy · 10 min · practice plan
Render nothing when the hide prop is true.
Passes when: #root should show visible.
4.Compose three componentsexercise · easy · 10 min · practice plan
Build a row from an icon, a name and a role component.
Passes when: #root should show star Ada Engineer.
5.Arrow function componentexercise · medium · 10 min · practice plan
Write the component as an arrow function instead of a declaration.
Passes when: #root should show arrow works.
6.Fix the two root elementsbug fix · easy · 8 min
A function cannot return two values; the siblings need a parent.
Passes when: #root should show both Title and Body.
7.Fix the return on its own linebug fix · easy · 8 min · practice plan
A line break after return ends the statement, so the component returns undefined.
Passes when: #root should show renders fine.
8.Fix the unclosed tagbug fix · easy · 8 min · practice plan
Every JSX tag must close, including void elements.
Passes when: #root should show both lines.
9.Fix the object dumped as JSONbug fix · medium · 8 min · practice plan
Stringifying the whole object shows its braces and quotes; read the field you meant.
Passes when: #root should show Name: Ada.
10.Fix the missing returnbug fix · easy · 8 min · practice plan
A component with no return renders nothing at all.
Passes when: #root should show arrow works.
Between them these tasks cover Naming, Single root and Fragments.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.