I want to render an HTML checkbox whose checked state is controlled by data.
Give a stateless component that receives an item
type { label: string, checked: bool}
,
Like so:
let component = ReasonReact.statelessComponent("TodoItem");
let make = (~item, _children) => {
render: _self => {
<li> <input type_="checkbox" {/*looking for something like this*/ item.checked ? "checked" : "" /* doesn't compile */}/> {ReasonReact.string(item.label)} </li>
}
}
How do I add the presence of the attribute checked
to the input
tag based on the item.checked == true
condition?