0Pricing
React Academy · Lesson

Cloning & Injecting Props with cloneElement

Use React.cloneElement to pass hidden props from parent to child components.

Welcome

In this lesson you will use React.cloneElement to clone a child element and inject extra props from the parent, without the child needing to know about them.

What Is cloneElement?

`React.cloneElement(element, props, ...children)` creates a new React element based on an existing one, merging the new props with the original props. The original element's type is preserved.
const clone = React.cloneElement(child, { active: true });

All lessons in this course

  1. props.children Fundamentals
  2. React.Children Utilities
  3. Named Slots via Object Props
  4. Cloning & Injecting Props with cloneElement
← Back to React Academy