cloneElement

A React function that copies an element while overriding or adding props, used by Slot to merge props onto a child.

In more detail

React.cloneElement(child, { className: merged }) returns a new element with the merged class. The React team now lists it as uncommon because it makes data flow harder to follow, but it remains the usual way to implement asChild.

Related terms

Taught in

References