Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 0.4 — Your First React App
React · Example 3 of 3

What StrictMode does in development

In development, StrictMode calls your component twice to catch code that changes things while rendering (like renders here). A production build calls it once. You'll learn why this helps in Topic 2.6.

A React app starts by creating a root on one HTML element with createRoot and rendering your top component into it; a real project gets the same setup from Vite in one command.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 5 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Write the full main.jsx for an app whose root element has the id app and whose top component is Shop from ./Shop.jsx, using StrictMode.

02

Make a live component that shows a heading My first React app and a paragraph with today's lesson number, 0.4.

Explain it without notes

01

What do react and react-dom each do?

02

Walk through the code that starts a React app, line by line.

03

What does StrictMode do, when, and why would you want it?

04

What do npm run dev and npm run build do in a Vite project?

What StrictMode does in development

Preview

Press Run to see the page.

Console

Nothing logged yet.

Expected console output

App rendered
App rendered
render count: 2