Created
June 15, 2021 14:20
-
-
Save marshallmurphy/4a3414ebbadcf4e94336f0d351f00140 to your computer and use it in GitHub Desktop.
This file contains 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
const App = () => { | |
const [todos, setTodos] = useState([]); | |
const addTodo = (e) => { | |
e.preventDefault(); | |
if (e.target[0].value.length > 0) { | |
const todo = e.target[0].value; | |
const newTodos = [...todos]; | |
newTodos.unshift(todo); | |
setTodos(newTodos); | |
e.target[0].value = null; | |
} | |
} | |
const completeTodo = (i) => { | |
} | |
const checkboxRow = (todo, i, checked = false) => ( | |
<Flex | |
width='100%' | |
justifyContent='space-between' | |
> | |
<Label | |
color='#fff' | |
> | |
<Checkbox | |
checked={checked} | |
onChange={() => completeTodo(i)} | |
/> | |
{todo} | |
</Label> | |
</Flex> | |
); | |
... | |
<Box width='350px'> | |
{todos.map((todo, i) => checkboxRow(todo, i))} | |
</Box> | |
</Flex> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment