Created
April 14, 2020 15:03
-
-
Save jsmanifest/b0d22ba9a63beb7cb50157de387cdfaf 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 ListComponent({ label, items = [], collapsed, toggle, limit, total }) { | |
return ( | |
<ul> | |
<p>{label}</p> | |
{items.map((member) => ( | |
<ListItem key={member}>{member}</ListItem> | |
))} | |
{total > limit && ( | |
<ListItem className="expand"> | |
<button type="button" onClick={toggle}> | |
{collapsed ? 'Expand' : 'Collapse'} | |
</button> | |
</ListItem> | |
)} | |
</ul> | |
) | |
} | |
function ListItem({ children, ...rest }) { | |
return <li {...rest}>{children}</li> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment