APIs

cloneElement

Creates a new element using an existing element as a template. Supplied properties override matching original properties; supplied children replace existing children. Prefer explicit component props or composition when possible.

Formal Syntax & Structure

react syntaxreact
cloneElement(element, props, ...children)

Parameters & Attributes

NameTypeDescription
elementReact elementExisting element to copy.
propsobject | nullOverrides; null retains original props.
...childrenReact nodesReplacement children if supplied.

Return Value

React element

New element; original remains unchanged.

Working Example

Example Snippetreact
import { cloneElement, createElement } from 'react';export default function App() {  const original = createElement('button', {type: 'button'}, 'Reserve');  return cloneElement(original, {disabled: true});}
React Reference