A Component Is Just A Bag Of Data
const ParentWithClick = ({ children }) => {
return (
<React.Fragment>
{React.Children.map(children || null, (child, i) => {
console.log(child);
return <child.type {...child.props} key={i} onClick={handleClick} />;
})}
</React.Fragment>
);
};
const App = () => (
<div>
<ParentWithClick>
<span>Click this span</span>
</ParentWithClick>
</div>
);Last updated