Skip to content
Learn Netverks

Lesson

Step 6/36 17% through track

jsx-basics

JSX basics

Last reviewed May 28, 2026 Content v20260528
Track mode
client_react
Means
In-browser React TSX
Reading
~2 min
Level
beginner

This lesson

This lesson teaches JSX basics: the concepts, APIs, and habits you need before advancing in React.

JSX is how most React teams author UI; fighting it without understanding the compile step leads to confusion.

You will apply JSX basics in contexts like: SPAs, dashboards, design-system-driven products, and React Native mobile apps.

Write TypeScript/TSX, click Run in browser—React 18 loads from CDN, JSX compiles in the tab, UI renders in the preview root, and printOutput feeds the terminal.

When you can explain the previous lesson's ideas without copying starter code.

JSX is a syntax extension that lets you write HTML-like markup inside JavaScript/TypeScript. It is not HTML: className replaces class, and JavaScript expressions go inside curly braces.

Rules that trip up beginners

  • One root element per return—or wrap siblings in a fragment (<>...</>).
  • All tags must close: <img />, <br />.
  • Embed expressions with {expression}—variables, function calls, ternaries.
  • Use className and htmlFor instead of class and for.

JSX compiles to function calls

<p>Hello, {name}</p>
// roughly becomes:
React.createElement('p', null, 'Hello, ', name);

Understanding this helps when debugging or reading stack traces—you rarely write createElement by hand in modern code.

Self-check

  1. Why must you use className in JSX?
  2. How do you embed a variable in JSX?

Challenge

Hello JSX

  1. Change the greeting text inside <p>.
  2. Add a {new Date().getFullYear()} expression in a second paragraph.
  3. Click Run and confirm the preview updates.

Done when: the preview shows your greeting and the current year.

Tip: JSX must have one parent element—or use <>...</> fragments. The transpiler turns tags into React.createElement calls.

Interview prep

What is JSX really?

Syntax sugar that compiles to React.createElement—not HTML. Use className, camelCase events, and one parent or Fragment per return.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs in your browser in a sandboxed frame. Backend runners appear when this track’s profile allows them.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • JSX vs HTML difference?
  • Fragment use case?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump