I'm injecting some props (isCollapsed) to a React.clone element I'm creating from children:
{React.Children.map(children, (child) => {
if (!React.isValidElement(child)) {
return null;
}
return React.cloneElement(child, {
...child.props,
isCollapsed: !isMenuOpen,
});
})}
I could assign an object to that element:
const newElement = React.cloneElement(child, {
...child.props,
isCollapsed: !isMenuOpen,
});
To that NewElement, is there a way to pass custom children?