- Home
- /
- Tutorials
- /
- React Tutorial
- /
- JSX Explained
JSX
JSX Explained
JSX is syntax sugar for one function call. Once you have seen what it compiles to, most of its rules stop being arbitrary.
What it becomes
A JSX tag compiles to React.createElement(type, props, ...children). That is all. Your browser never sees JSX - a compiler rewrites it first, and on this site that happens as you press Run.
The same element, written twice
jsx
// JSX
const fromJsx = <h3 className="title">Hello</h3>
// Exactly what the compiler produces
const fromCall = React.createElement("h3", { className: "title" }, "Hello")
const root = ReactDOM.createRoot(document.getElementById("root"))
root.render(
<div>
{fromJsx}
{fromCall}
<p>Both lines above produced identical output.</p>
</div>
)