Created
May 28, 2021 07:50
-
-
Save ravid7000/6ff2775d289ebdab5c3d4cea7abed75b 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
import React from 'react'; | |
import './App.css'; | |
import { useTodoController } from './App.controller'; | |
const App = () => { | |
const { state, actions } = useTodoController(); | |
return ( | |
<div className="container"> | |
<form onSubmit={actions.addTodo}> | |
<input | |
placeholder="Add todo" | |
value={state.todoName} | |
onChange={actions.changeTodoName} | |
/> | |
</form> | |
<ul> | |
{state.todoList.map((todo) => ( | |
<li | |
key={todo.id} | |
> | |
<button onClick={() => actions.removeTodo(todo.id)}>×</button> | |
<span className={todo.done ? 'done todo-name' : 'todo-name'} onClick={() => actions.toggleTodo(todo.id)}>{todo.name}</span> | |
</li> | |
))} | |
</ul> | |
</div> | |
) | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment