Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save szaranger/0e852f82c526b24aee84067dfa3d9b0d to your computer and use it in GitHub Desktop.
Save szaranger/0e852f82c526b24aee84067dfa3d9b0d to your computer and use it in GitHub Desktop.
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