What is the React cloneElement function?

The React.cloneElement() function returns a copy of a specified element. Additional props and children can be passed on in the function. You would use this function when a parent component wants to add or modify the prop(s) of its children.

The following illustration ​describes the function signature:

Function signature
Function signature

Code

The following code snippet shows how the parent component (ParentComp)can add a new prop (newProp)to its child component (MyButton).

import React from 'react';
require('./style.css');

import ReactDOM from 'react-dom';
import App from './app.js';

ReactDOM.render(
  <App />, 
  document.getElementById('root')
);

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved