If you want to make the existence of an html attribute dynamic? You can directly pass checked={completed} so if completed is true checkbox will be checked otherwise unchecked.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | import React from 'react'; export class TodoListItem extends React.Component<any, any> { render() { const {label, completed} = this.props; return ( <li className="todo"> <label> <input type="checkbox" checked={completed} /> {label} </label> </li> ); } } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.