mirror of
https://github.com/microsoft/frontend-bootcamp.git
synced 2026-01-26 14:56:42 +08:00
* update to hooks * more class to function * cleanup * finish ts final * update html lesson * add lessons page * clean up * move getters into context * adding type * fix bug * step 5 cleanup * init final pass * text tweak * fix ternaries * readme cleanup * fixed root readme
17 lines
453 B
TypeScript
17 lines
453 B
TypeScript
import React from 'react';
|
|
import { Todo } from '../TodoApp.types';
|
|
import { AppContext } from '../TodoApp';
|
|
|
|
export const TodoListItem = (props: Todo) => {
|
|
const { label, status, id } = props;
|
|
const { toggleCompleted } = React.useContext(AppContext);
|
|
|
|
return (
|
|
<li className="todo">
|
|
<label>
|
|
<input type="checkbox" checked={status === 'completed'} onChange={() => toggleCompleted(id)} /> {label}
|
|
</label>
|
|
</li>
|
|
);
|
|
};
|