Created
July 17, 2020 20:06
-
-
Save DZuz14/b9015fa82db4128a8465f86664eec3b6 to your computer and use it in GitHub Desktop.
React Children Map 2
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
{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