Skip to content

Instantly share code, notes, and snippets.

@jsmanifest
Created April 14, 2020 15:03
Show Gist options
  • Save jsmanifest/b0d22ba9a63beb7cb50157de387cdfaf to your computer and use it in GitHub Desktop.
Save jsmanifest/b0d22ba9a63beb7cb50157de387cdfaf to your computer and use it in GitHub Desktop.
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