The React.createElement Signature
What you'll learn: How JSX elements map directly to createElement() function arguments.
When JSX compiles to JavaScript, every element becomes a React.createElement() call. Understanding this function's signature reveals exactly what JSX is doing under the hood.
The Three-Argument Structure
React.createElement() takes three arguments:
React.createElement(type, props, children)
1. type — The element type (string for HTML tags, function/class for components)
2. props — An object containing all attributes and props (or null if none)
3. children — Everything nested inside the element (can be multiple arguments)
Mapping JSX to createElement
When you write JSX like this:
<h1 className="title">Hello World</h1>
It compiles to:
React.createElement('h1', { className: 'title' }, 'Hello World')
Notice how:
- The tag name
'h1'becomes the type (first argument) - The attribute
className="title"becomes a props object (second argument) - The text content
'Hello World'becomes the children (third argument)
Multiple Children
Children can be multiple arguments:
<div><span>First</span><span>Second</span></div>
Becomes:
React.createElement(
'div',
null,
React.createElement('span', null, 'First'),
React.createElement('span', null, 'Second')
)
Key Takeaway: Every JSX element is syntactic sugar for React.createElement(type, props, children) — the type defines what to render, props define how to configure it, and children define what's inside.