Write a component that renders an h2 saying Hello React, and render it.
Acceptance criteria
- 1.#root should show Hello React.
React Tutorial · React Introduction
These 10 tasks go with the What Is React 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: “React is a library for describing what should be on screen. You never write the steps to update the page — you describe the result, and React works out the difference.” .
1.Render a headingexercise · easy · 10 min
Write a component that renders an h2 saying Hello React, and render it.
Passes when: #root should show Hello React.
2.Render a paragraphexercise · easy · 10 min · practice plan
Render a component containing a paragraph with the text Ready to build.
Passes when: #root should show Ready to build.
3.Two componentsexercise · easy · 10 min · practice plan
Write two components and render both inside a div.
Passes when: #root should show First Second.
4.Show a valueexercise · easy · 10 min · practice plan
Declare a constant and display it inside a component with braces.
Passes when: #root should show count is 7.
5.Nest a componentexercise · medium · 10 min · practice plan
Render a Badge component inside a Card component.
Passes when: #root should show Card with badge.
6.Fix the lowercase componentbug fix · easy · 8 min
JSX treats a lowercase tag as an HTML element, so the component never runs.
Passes when: #root should show Hello React.
7.Fix the missing render callbug fix · easy · 8 min · practice plan
The component is defined but never handed to the root.
Passes when: #root should show Ready to build.
8.Fix the component called as a functionbug fix · easy · 8 min · practice plan
Calling a component inlines its result instead of creating an element React manages.
Passes when: #root should show used as a tag.
9.Fix the value shown as textbug fix · easy · 8 min · practice plan
Without braces the variable name is printed literally.
Passes when: #root should show count is 7.
10.Fix the wrong mount nodebug fix · medium · 8 min · practice plan
createRoot was given an element that does not exist, so nothing appears.
Passes when: #root should show mounted correctly.
Between them these tasks cover Components, Rendering and createRoot.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.