Created
November 6, 2021 08:41
-
-
Save szaranger/0e852f82c526b24aee84067dfa3d9b0d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Buttons({ children }) { | |
const newProps = { | |
className: "highlight", | |
onClick: () => console.log("Clicked!") | |
}; | |
return ( | |
<> | |
{children.map((child, index) => | |
React.isValidElement(child) && | |
React.cloneElement(child, { ...newProps, key: index }) | |
)} | |
</> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment