JSX and React Elements

Harry · 22 Sep 2026 · 1 views
Log in to track your progress and mark lessons complete.

What Is JSX?

JSX is a JavaScript syntax extension that looks like HTML but compiles to React.createElement calls.

Syntax Rules

  • Single root element (or fragment).
  • Close all tags; camelCase attributes (className, onClick).
  • JavaScript goes inside curly braces.

Expressions in JSX

<h2>{user.name}</h2>
{isAdmin ? <Badge /> : null}
{items.map(i => <li key={i.id}>{i.name}</li>)}

Fragments

Group elements without extra DOM nodes using <>...</>.

Key Points

  • JSX is JavaScript with XML-like syntax.
  • Keys help React track list items.
  • children holds content between tags.
Share this post:

Comments (0)

Please login or register to comment.

Create a free account to keep reading

You've enjoyed a free tutorial! Register (it's free) to unlock every tutorial, track your progress and save code.

or sign in with your account

Already have an account? Log in