Last active
September 15, 2020 11:04
-
-
Save sydcanem/06b29365b3c8115bf7cff5a80c4bf3fa 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
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