createElement
Creates a React element; the underlying call JSX compiles to.
Syntax
createElement(type, props, ...children) Parameters
| Name | Type | Required | Description |
|---|---|---|---|
type | string | component | Yes | A tag name string or a component function/class. |
props | object | No | Element props, or null for none. |
children | node | No | Zero or more child nodes. |
Returns
element — A React element object describing what to render.
Examples
import { createElement } from 'react';
createElement('h1', { className: 'title' }, 'Hello');
// Equivalent JSX:
<h1 className="title">Hello</h1>
Notes
JSX is syntactic sugar for createElement, so you rarely call it directly.
Returned elements are immutable plain objects. Prefer JSX for readability;
use createElement only when JSX is unavailable or for dynamic element types.