Skip to content

Instantly share code, notes, and snippets.

@DZuz14
Created July 17, 2020 20:06
Show Gist options
  • Save DZuz14/b9015fa82db4128a8465f86664eec3b6 to your computer and use it in GitHub Desktop.
Save DZuz14/b9015fa82db4128a8465f86664eec3b6 to your computer and use it in GitHub Desktop.
React Children Map 2
{React.Children.map(children, child => {
const id = child.props.children[0].props.id
const collapsed = React.cloneElement(child.props.children[0], {
handleOpen
})
const expanded = child.props.children[1]
return (
<div>
{collapsed}
{id === open && expanded}
</div>
)
})}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment