Skip to content

Instantly share code, notes, and snippets.

@ravid7000
Created May 28, 2021 07:50
Show Gist options
  • Save ravid7000/6ff2775d289ebdab5c3d4cea7abed75b to your computer and use it in GitHub Desktop.
Save ravid7000/6ff2775d289ebdab5c3d4cea7abed75b to your computer and use it in GitHub Desktop.
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)}>&times;</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