$$typeofa symboltype"li"keynullrefnullprops{…}$$reactjsx-runtimelast render

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.

12 scenes · ←/→ to move
<li className="row">you writethe compiler_jsx("li", {…})build time ↑run time ↓jsxProd()$$typeoftype key refprops$$a plain object: nothing after it knows JSX existed

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
What you write, and what the compiler emits in productionOur example, not 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});
}
Where the file sitsOur example, not from the source
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 dive
<li>"li"a string · a host element<Row>ƒRowa variable · a componentthe first letter decides

React 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

Check yourselfYou write <row /> for a component named row. What reaches React?
From the source
A parent that uses Row, and what it compiles toOur example, not from the source
function 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"
  });
}
jsxswritten out · cannot movelililijsxan array · each item needs a key[]lialiblicin production both are jsxProd

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

Check yourselfA parent has several children with no keys, and there is no warning. Why?
From the source
The dev/prod switch, with its comment droppedReactJSX.js:17–26 ↗
const jsx: any = __DEV__
  ? jsxProdSignatureRunningInDevWithDynamicChildren
  : jsxProd;
const jsxs: any = __DEV__
  ? jsxProdSignatureRunningInDevWithStaticChildren
  : jsxProd;

const jsxDEV: any = __DEV__ ? _jsxDEV : undefined;
Which one the compiler picksOur example, not from the source
// 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>   // ← warns
config, from the compilerclassName: "row"key: 1jsxProd$$typeoftype"li"key"1"refnullprops{className}$$'' + 1 → "1"no key? config isreused as props

React 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
The production path, without its comments and the experimental 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);
}
$$typeofa symboltype"li"keynullrefnullprops{…}$$no methods · no parent · no stateno link to the screen

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
The production element, inside 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,
};
element.type is one of"li"a stringhost elementƒ Rowa functioncomponentSymbolreact.fragmentbuilt-in{ $$typeof }memo · lazy · …wrapper

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.

  1. A string, like "li": a host element. Only the renderer knows what to do with it; in the browser it becomes a DOM node.
  2. A function, like Row: a component. Call it and you get more elements.
  3. A symbol, like Symbol.for('react.fragment') for <>…</>: one of React’s built-ins, recognised by its symbol.
  4. An object with its own $$typeof, like the result of memo, forwardRef, lazy or a context: a wrapper around something else.

The ideaEverything polymorphic about an element is in type

From the source
What type holds
What you wrote`type` holdsMeaning
<li />the string "li"A host element; only the renderer knows what to do with it
<Row />the function RowA 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
$$typeoftyperefcopy, for compatibilitypropsclassName · childrenprops.refkeynever a prop

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
The start of 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;
Symbol.forthe realm's registry'react.transitional.element'copy Aof React$$copy Bof React$$===

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

Check yourselfTwo copies of React are in your bundle. Does isValidElement from copy A accept an element made by copy B?
From the source
The tag vocabulary, abridged: the first five symbolsReactSymbols.js:15–20 ↗
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');
isValidElementJSON.parse(…)"$$typeof":"react.element"a string: JSON has no symbols$$typeoftypeprops$$a symbol: passes

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
The attack, if $$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 element
The check that stops itReactJSXElement.js:891–897 ↗
export function isValidElement(object) {
  return (
    typeof object === 'object' &&
    object !== null &&
    object.$$typeof === REACT_ELEMENT_TYPE
  );
}
$$typeoftypekeyrefprops$$production$$typeoftypekeyrefgetterpropsfrozen_ownerwho made it_store{validated}_debugStackan Error_debugTask_debugInfo$$development · frozen

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

Check yourselfWhy is the validated flag stored on element._store and not on the element itself?
From the source
The two objects, field by field
FieldProductionDevelopment
$$typeof, type, key, propspresentpresent
refplain propertynon-enumerable; a warning getter if a ref was passed, else null
_ownerabsentthe component that created this element
_store.validatedabsentkey-check state, on a side object so the element can be frozen
_debugStackabsentan Error object, captured per element
_debugTaskabsenta console.createTask handle
_debugInfoabsentServer Component debug data
frozen?noObject.freeze on the element and on props
Capping the stack depth for each element’s _debugStackReactJSXElement.js:375–378 ↗
const previousStackTraceLimit = Error.stackTraceLimit;
Error.stackTraceLimit = ownerStackTraceLimit;      // ← 10
debugStackDEV = Error('react-stack-top-frame');
Error.stackTraceLimit = previousStackTraceLimit;
The end of 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);
  }
}
jsx runtime(type, config, key)createElement(type, config, …children)childrena propextra argumentspropsconfig, reusedalways newdefaultProps—resolvedkey spreadwarnssilent

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 two ways to make a slip
the jsx runtime`createElement(type, config, ...children)`
Childrena prop inside configextra arguments, collected into props.children
Props objectreuses config when no key was spreadalways allocates a new object
defaultPropsnot resolvedresolved from type.defaultProps (line 704)
Key-spread warningyes, in developmentno
In createElement, and nowhere in jsxProdReactJSXElement.js:704–708 ↗
if (type && type.defaultProps) {
  const defaultProps = type.defaultProps;
  for (propName in defaultProps) {
    …
      props[propName] = defaultProps[propName];
ReactJSXElement.js · 9052jsxProd2913ReactElement1705isValidElement8916jsxDEVImpl4697createElement6108owner stacks61ReactJSX.js1ReactSymbols4≈500 lines are dev-only warnings

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:

  1. ReactJSX.js, all 28 lines: the dev/prod switch.
  2. Lines 291–348, jsxProd: the production path, end to end.
  3. Lines 170–283, ReactElement: the production branch first, then development. Note where Object.freeze sits.
  4. shared/ReactSymbols.js: the tag vocabulary. It comes back in the reconciler.
  5. Lines 891–905: isValidElement and isLazyType.
  6. Lines 469–604, jsxDEVImpl: the warnings, for key spread, static children and the key getter.
  7. Lines 610–746, createElement: the older path, for contrast. defaultProps is at 704.
  8. 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
An exercise for a development build of any React appOur example, not 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, _debugInfo
$$typeofa symboltype"li"keynullrefnullprops{…}$$reactjsx-runtimelast render

React 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: jsx or jsxs says 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.
  • key is not a prop. It is lifted out, and turned into a string, before props exist.
  • type carries all the variety: a string, a function, a symbol or a wrapper object.
  • Symbol.for gives every copy of React the same seal, and a symbol cannot be forged from JSON.
  • The development element is a different object: an Error per 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.

Dive 04: From element to fiber ↓