Skip to content

Instantly share code, notes, and snippets.

@sydcanem
Last active September 15, 2020 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sydcanem/06b29365b3c8115bf7cff5a80c4bf3fa to your computer and use it in GitHub Desktop.
Save sydcanem/06b29365b3c8115bf7cff5a80c4bf3fa to your computer and use it in GitHub Desktop.
import React from "react";
import Checkbox from "./Checkbox";
import { status } from "./constants";
export default function List(props) {
const { items } = props;
return (
<ul>
{items.map((item) => {
let childList = null;
if (Array.isArray(item.items)) {
childList = <List items={item.items} />;
}
return (
<li key={item.id}>
<Checkbox
id={item.id}
name={item.name}
checked={item.status === status.checked}
indeterminate={item.status === status.indeterminate}
/>
<label htmlFor={item.name}>{item.name}</label>
{childList}
</li>
);
})}
</ul>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment