React · Dive 03 of 14
From JSX call site to element
The order slip at the front counter
A React element is not a component, not an instance and not a DOM node. It is an order slip: a plain object with five fields, filled in by a short function at the react counter and thrown away on the next render. Diffing, scheduling, effects and the DOM all happen further down the building, and none of them knows JSX ever existed. The description of the UI is meant to be inert and cheap.
React 03 · 1 of 13
A letter translated before the day starts
You write JSX, but the browser never sees it. Before your app runs, the compiler your bundler runs translates every tag into an ordinary function call. It is the translator who rewrites your letter into the counter’s own language before the town hall opens.
For <li className="row">{item.name}</li> the production output is _jsx("li", {className: "row", children: item.name}), and the _jsx comes from an import the compiler adds itself: import {jsx as _jsx} from "react/jsx-runtime". That is why you no longer import React to use JSX.
Each call runs once per tag and hands back a plain object, the element. That is the whole hand-off. The compiler works at build time, jsxProd at run time, and nothing after the object knows that JSX was ever involved.
The code for all of it sits on the top floor, in packages/react/: the entry points jsx-runtime.js and jsx-dev-runtime.js, a 28-line switch called ReactJSX.js, and ReactJSXElement.js, 905 lines, which is everything in this dive.
The ideaJSX is gone before your code runs; a function call is left
From the source
function Row({item}) {
return <li className="row">{item.name}</li>;
}
// becomes
import {jsx as _jsx} from "react/jsx-runtime"; // ← you never imported React
function Row({item}) {
return _jsx("li", {className: "row", children: item.name});
}packages/react/
├── jsx-runtime.js # the entry point your bundler imports
├── jsx-dev-runtime.js
└── src/jsx/
├── ReactJSX.js # 28 lines: picks the dev or prod implementation
└── ReactJSXElement.js # 905 lines: everything in this diveReact 03 · 2 of 13
A capital letter is the whole rule
Look at what the first argument becomes. A lowercase tag becomes a string: <li> gives "li". A capitalised tag becomes a variable: <Row> gives Row, the function itself. The compiler decides by the first letter alone. That is the entire mechanism behind “components must be capitalised”; what the component returns plays no part.
Calling _jsx(Row, …) does not call Row. It only writes “a Row goes here” on a slip. React calls Row later, during render, and that call is what produces the "li" element inside it.
Two more details in the call. Children became a prop: there is no separate channel for them, which is why <li children={x} /> gives the same result as putting x between the tags. The key did not: the compiler passes it as a third argument, beside the props rather than among them.
The ideaLowercase is a string, capitalised is a variable
From the source
Row, and what it compiles toOur example, not from the sourcefunction List({items}) {
return <ul>{items.map(item => <Row key={item.id} item={item} />)}</ul>;
}
function List({items}) {
return _jsx("ul", {
children: items.map(item => _jsx(Row, {item: item}, item.id)), // ← Row the function, not "Row"
});
}React 03 · 3 of 13
Two functions that differ only in development
The compiler has two names to choose from. It emits jsxs when a tag has several children written out in the source, and jsx otherwise. In production both are the same function, jsxProd; ReactJSX.js says so in three lines.
The difference exists in development, for one reason. Children written out one by one cannot change order between renders, so they need no keys. An array passed as a child can: it may be filtered, sorted or grown. So jsx checks each item of an array for a key, and jsxs does not check the children it was told are fixed.
That makes the compiler part of the contract. The missing-key warning depends on what the compiler told React at the call site, not on React guessing at run time.
The ideaThe compiler tells React which children can move
From the source
const jsx: any = __DEV__
? jsxProdSignatureRunningInDevWithDynamicChildren
: jsxProd;
const jsxs: any = __DEV__
? jsxProdSignatureRunningInDevWithStaticChildren
: jsxProd;
const jsxDEV: any = __DEV__ ? _jsxDEV : undefined;// jsxs: three children written out, no keys needed
<ul><li>a</li><li>b</li><li>c</li></ul>
// jsx: one child, which is an array; each item is checked for a key
<ul>{['a','b','c'].map(s => <li>{s}</li>)}</ul> // ← warnsReact 03 · 4 of 13
What the clerk does, all of it
jsxProd is the clerk at the counter, and the whole production job is under sixty lines. It takes the three arguments, type, config (the props object the compiler built) and maybeKey, and does three things.
First, the key. If one was passed, it becomes a string: key = '' + maybeKey. So key={1} and key="1" produce the same element, and an object used as a key becomes "[object Object]", so every item keyed by an object collides with every other. If a key was spread in through the props, that one wins over the positional one.
Second, the props. If there is no key in config, the clerk hands the compiler’s object straight through as props, with no copy. That is safe only because the compiler always writes a fresh object literal; the source notes that createElement cannot do the same, because people call it by hand with shared objects.
Third, when a key was spread in, the clerk copies every other prop into a new object instead of deleting key from the old one. The source gives the reason: delete would make V8 switch the object to dictionary mode, which is slower to read, and props are read many times per render. Then it calls ReactElement and returns the result.
The ideaKeys become strings; props are reused when they can be
From the source
enableOptimisticKey branchReactJSXElement.js:291–348 ↗export function jsxProd(type, config, maybeKey) {
let key = null;
if (maybeKey !== undefined) {
key = '' + maybeKey; // ← keys are always coerced to strings
}
if (hasValidKey(config)) {
key = '' + config.key; // ← a spread key wins over a positional one
}
let props;
if (!('key' in config)) {
props = config; // ← fast path: reuse the object as-is
} else {
props = {};
for (const propName in config) {
if (propName !== 'key') {
props[propName] = config[propName];
}
}
}
return ReactElement(type, key, props, getOwner(), undefined, undefined);
}React 03 · 5 of 13
Five fields and nothing else
ReactElement is an ordinary function, not a constructor, and in production it returns exactly one object literal with five fields: $$typeof, type, key, ref and props.
Notice what is missing. There are no methods, no pointer to a parent, no state, and no link to anything on screen. An element is a value, like a number or a string: a description of what should be there, written down and handed on.
That is why it can be thrown away. Every render makes new slips for the whole subtree it touches, and the old ones become garbage. Whatever has to survive between renders, state, the DOM node, pending work, lives somewhere else, on the fiber that Dive 04 is about.
The ideaAn element is a value: written, read, thrown away
From the source
ReactElementReactJSXElement.js:226–237 ↗// In prod, `ref` is a regular property and _owner doesn't exist.
element = {
// This tag allows us to uniquely identify this as a React Element
$$typeof: REACT_ELEMENT_TYPE,
// Built-in properties that belong on the element
type,
key,
ref,
props,
};React 03 · 6 of 13
One field, four kinds of thing
Of the five fields, type does the most work, because it can hold four different kinds of value, and the reconciler switches on which one it finds.
- A string, like
"li": a host element. Only the renderer knows what to do with it; in the browser it becomes a DOM node. - A function, like
Row: a component. Call it and you get more elements. - A symbol, like
Symbol.for('react.fragment')for<>…</>: one of React’s built-ins, recognised by its symbol. - An object with its own
$$typeof, like the result ofmemo,forwardRef,lazyor a context: a wrapper around something else.
The ideaEverything polymorphic about an element is in type
From the source
type holds| What you wrote | `type` holds | Meaning |
|---|---|---|
<li /> | the string "li" | A host element; only the renderer knows what to do with it |
<Row /> | the function Row | A component; call it to get more elements |
<>…</> | Symbol.for('react.fragment') | A built-in, identified by symbol |
<Memo /> | {$$typeof: REACT_MEMO_TYPE, type: …} | A wrapper object from memo, forwardRef, lazy or context |
React 03 · 7 of 13
The key is not a prop
The key travels on the outside of the slip, not in the props. jsxProd lifts it out before props exists. React needs the key during list reconciliation, to pair old children with new ones, before it looks at props at all, and keeping it out of props means a component can neither shadow it nor forget to pass it on.
So your component never sees its own key. In development, reading props.key triggers a warning getter, to tell you so.
ref is going the other way. In React 19 it became a normal prop, and the source says props.ref is the source of truth. The top-level element.ref is only kept for compatibility: ReactElement copies it from props.ref, and in development reading it logs a deprecation warning when a ref was passed.
The ideaThe key stays outside the props; ref has moved inside
From the source
ReactElement: ref is read from the propsReactJSXElement.js:170–179 ↗function ReactElement(type, key, props, owner, debugStack, debugTask) {
// Ignore whatever was passed as the ref argument and treat `props.ref` as
// the source of truth. The only thing we use this for is `element.ref`,
// which will log a deprecation warning on access. In the next release, we
// can remove `element.ref` as well as the `ref` argument.
const refProp = props.ref;
// An undefined `element.ref` is coerced to `null` for
// backwards compatibility.
const ref = refProp !== undefined ? refProp : null;React 03 · 8 of 13
A seal that is the same in every copy
The first field, $$typeof, is the seal on the slip. It holds a symbol from shared/ReactSymbols.js: REACT_ELEMENT_TYPE, made with Symbol.for('react.transitional.element').
Symbol.for is not Symbol(). Symbol('x') makes a new, unique symbol every time. Symbol.for('x') looks the name up in a registry shared by the whole JavaScript realm and returns the same symbol every time. So two separately bundled copies of React, which each run that line, get the very same seal and agree on what an element is.
Duplicate copies of React still break, but not here. Hooks rely on state that belongs to one copy (its dispatcher), so a component rendered by copy A and calling hooks from copy B fails. Elements pass between copies fine. That is why the usual symptom of two Reacts in one bundle is “invalid hook call”, not “invalid element”.
The ideaSymbol.for gives every copy of React the same seal
From the source
export const REACT_LEGACY_ELEMENT_TYPE: symbol = Symbol.for('react.element');
export const REACT_ELEMENT_TYPE: symbol = Symbol.for(
'react.transitional.element',
);
export const REACT_PORTAL_TYPE: symbol = Symbol.for('react.portal');
export const REACT_FRAGMENT_TYPE: symbol = Symbol.for('react.fragment');React 03 · 9 of 13
A seal JSON cannot forge
The symbol has a second job, and it is about security. Suppose your app renders a field from server JSON that a user controls, such as a message body. If $$typeof were a string, an attacker could store an object shaped exactly like an element, with dangerouslySetInnerHTML in its props, and <div>{message.body}</div> would render it.
It cannot happen, because JSON.parse produces strings, numbers, booleans, arrays, objects and null, and never a symbol. A forged $$typeof can only be a string, and isValidElement compares against the real symbol with ===. That one comparison is the whole defence.
The general lesson reaches beyond React: when untrusted input must not be able to forge a value, represent that value with something the untrusted channel cannot carry.
A note for older material: the symbol’s name changed. ReactSymbols.js still exports REACT_LEGACY_ELEMENT_TYPE, which is Symbol.for('react.element'), so tooling that hard-codes the old name will not recognise current elements.
The ideaUse a value the untrusted channel cannot carry
From the source
$$typeof were a stringOur example, not from the source// attacker-controlled value, stored and returned as JSON
{
"$$typeof": "react.element",
"type": "div",
"props": { "dangerouslySetInnerHTML": { "__html": "<img onerror=… />" } }
}
<div>{message.body}</div> // ← would render a forged elementexport function isValidElement(object) {
return (
typeof object === 'object' &&
object !== null &&
object.$$typeof === REACT_ELEMENT_TYPE
);
}React 03 · 10 of 13
The development slip is a different object
In development, ReactElement builds a heavier slip. It still has the five fields, but ref becomes a hidden property with a warning getter, and more stamps are added: _owner (the component that created the element), _store.validated (whether its keys were checked), _debugStack, _debugTask and _debugInfo (Server Component debug data). Then the element and its props are frozen.
The expensive stamp is _debugStack. To show the “owner stack” in warnings, React captures an Error, and with it a stack trace, at each JSX call. It limits the cost twice: it sets Error.stackTraceLimit to 10 while capturing, and it keeps a budget, after which elements share one pre-made placeholder stack. This is why you should never profile element creation in development.
The freeze only happens in development. Assigning to a prop, props.value = 1, throws a TypeError there, because the object is frozen and module code is strict. In production the same line quietly succeeds. And the freeze is shallow: props.items.push(x) changes the array in both builds and never throws.
The ideaDevelopment stamps, laminates and slows every slip
From the source
| Field | Production | Development |
|---|---|---|
$$typeof, type, key, props | present | present |
ref | plain property | non-enumerable; a warning getter if a ref was passed, else null |
_owner | absent | the component that created this element |
_store.validated | absent | key-check state, on a side object so the element can be frozen |
_debugStack | absent | an Error object, captured per element |
_debugTask | absent | a console.createTask handle |
_debugInfo | absent | Server Component debug data |
| frozen? | no | Object.freeze on the element and on props |
_debugStackReactJSXElement.js:375–378 ↗const previousStackTraceLimit = Error.stackTraceLimit;
Error.stackTraceLimit = ownerStackTraceLimit; // ← 10
debugStackDEV = Error('react-stack-top-frame');
Error.stackTraceLimit = previousStackTraceLimit;ReactElement in development: the side store, then the freeze (abridged)ReactJSXElement.js:240–280 ↗if (__DEV__) {
// The validation flag is currently mutative. We put it on
// an external backing store so that we can freeze the whole object.
element._store = {};
Object.defineProperty(element._store, 'validated', { … value: 0 });
Object.defineProperty(element, '_debugInfo', { … value: null });
Object.defineProperty(element, '_debugStack', { … value: debugStack });
Object.defineProperty(element, '_debugTask', { … value: debugTask });
if (Object.freeze) {
Object.freeze(element.props);
Object.freeze(element);
}
}React 03 · 11 of 13
createElement is not jsx
Before the new JSX transform in React 17, every tag compiled to React.createElement. It still exists, and it is not the same function with a new name.
It takes children as extra arguments and collects them into props.children. It always allocates a new props object, because it cannot assume the caller passed a fresh one. And it still resolves type.defaultProps, at line 704; jsxProd has no such code.
That last row matters. Class components are unaffected, because the reconciler fills in their defaults itself. For function components React 19 no longer does that, so defaultProps on a function component only takes effect when the element was built with createElement. Default parameter values have no such split: the language resolves them when the function is called.
The ideaFor function components, use default parameters
From the source
| the jsx runtime | `createElement(type, config, ...children)` | |
|---|---|---|
| Children | a prop inside config | extra arguments, collected into props.children |
| Props object | reuses config when no key was spread | always allocates a new object |
defaultProps | not resolved | resolved from type.defaultProps (line 704) |
| Key-spread warning | yes, in development | no |
createElement, and nowhere in jsxProdReactJSXElement.js:704–708 ↗if (type && type.defaultProps) {
const defaultProps = type.defaultProps;
for (propName in defaultProps) {
…
props[propName] = defaultProps[propName];React 03 · 12 of 13
How to read the file yourself
About 500 of the 905 lines in ReactJSXElement.js are development-only warnings, so read it in this order, production first:
ReactJSX.js, all 28 lines: the dev/prod switch.- Lines 291–348,
jsxProd: the production path, end to end. - Lines 170–283,
ReactElement: the production branch first, then development. Note whereObject.freezesits. shared/ReactSymbols.js: the tag vocabulary. It comes back in the reconciler.- Lines 891–905:
isValidElementandisLazyType. - Lines 469–604,
jsxDEVImpl: the warnings, for key spread, static children and the key getter. - Lines 610–746,
createElement: the older path, for contrast.defaultPropsis at 704. - Lines 61–95: the owner-stack setup, with its comments on V8, SpiderMonkey and JavaScriptCore.
The ideaProduction path first; the warnings last
From the source
// in your component, or the console with a component in scope
console.log(<li className="row">hi</li>);
// expand it: $$typeof, type, key, props, and the hidden
// _owner, _store, _debugStack (an Error), _debugTask, _debugInfoReact 03 · 13 of 13
What to keep
- An element is a value: five fields, no methods, no link to the screen, thrown away every render.
- The compiler is part of the contract:
jsxorjsxssays whether children are fixed, and reusing the props object is safe only because the compiler always writes a fresh one. - A capital letter is what makes a tag a component: lowercase becomes a string, capitalised becomes the variable.
keyis not a prop. It is lifted out, and turned into a string, before props exist.typecarries all the variety: a string, a function, a symbol or a wrapper object.Symbol.forgives every copy of React the same seal, and a symbol cannot be forged from JSON.- The development element is a different object: an
Errorper JSX call, a side store for validation, and a shallow freeze that only development enforces.
Read from facebook/react at dcd4ec28a1 (react 19.3.0, 26 July 2026). Line numbers are from that commit.