author avatar

syedsibtain

Tue Jan 10 2023

I discovered that manipulating the elements is possible with React.cloneElement() function. This can be used when a parent component wants to add or change the props of its children.

React.cloneElement(element, [props], [...children])

The function mentioned above makes a clone of the first parameter which is element and returns an element with the desired changes. We can further pass props to it as well.