MCPcopy Create free account
hub / github.com/adobe/react-spectrum / TodoItems

Function TodoItems

examples/rsp-webpack-4/src/ToDoItems.js:3–26  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

1import {CheckboxGroup, Checkbox, Flex} from '@adobe/react-spectrum';
2
3function TodoItems(props) {
4 function removeItem(id) {
5 //add selected item to the completed list
6 const found = props.list.find(element => element.id === id);
7 if (found) {
8 props.updateCompleted(found.task);
9 }
10
11 //remove the item from the list
12 props.handleList(props.list.filter(item => item.id !== id));
13 }
14
15 const elements = props.list.map(item => (
16 <Checkbox onChange={() => removeItem(item.id)} key={item.id} value={item.task}>
17 {item.task}
18 </Checkbox>
19 ));
20
21 return (
22 <CheckboxGroup aria-label="to-do list">
23 <Flex direction="column">{elements}</Flex>
24 </CheckboxGroup>
25 );
26}
27
28export default TodoItems;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected