Learn the concept
JSX
JSX is a syntax extension that allows writing HTML-like code in JavaScript. React uses it because it provides a familiar, readable way to describe UI structure while leveraging JavaScript's full power for logic and expressions.
What is JSX:
How JSX Works:
jsx() / jsxs() from react/jsx-runtime — no need to import React in files that only use JSXReact.createElement() calls (required import React in every file)Key Differences from HTML:
className instead of classhtmlFor instead of forBenefits:
{}// JSX syntax
const element = (
<div className="greeting">
<h1>Hello, World!</h1>
<p>Welcome to React</p>
</div>
);
// Modern transform (React 17+) — compiles to:
import { jsx as _jsx, jsxs as _jsxs } from 'react/jsx-runtime';
const element = _jsxs('div', {
className: 'greeting',
children: [
_jsx('h1', { children: 'Hello, World!' }),
_jsx('p', { children: 'Welcome to React' })
]
});
// No need to import React! The transform is automatic.
// Legacy transform (pre-React 17) compiled to:
// React.createElement('div', { className: 'greeting' }, ...)Using JSX to build reusable UI component libraries with consistent APIs
JSX compiles to function calls that work identically on server and client for SSR/SSG
Translating Figma designs to JSX component trees with design tokens
Build a component that demonstrates all JSX expression types (conditionals, loops, embedding expressions)
Configure a custom JSX runtime to understand how JSX compilation works under the hood