Reformat code to have 4 indent for a tab
This commit is contained in:
parent
78fde10f19
commit
01cbf39684
102
src/App.tsx
102
src/App.tsx
@ -3,66 +3,66 @@ import './App.css';
|
||||
import Todo from "./Todo";
|
||||
|
||||
interface TodoItem {
|
||||
id: number;
|
||||
text: string;
|
||||
completed: boolean;
|
||||
id: number;
|
||||
text: string;
|
||||
completed: boolean;
|
||||
}
|
||||
|
||||
function App() {
|
||||
const [todos, setTodos] = useState<TodoItem[]>([]);
|
||||
const [text, setText] = useState("");
|
||||
const [todos, setTodos] = useState<TodoItem[]>([]);
|
||||
const [text, setText] = useState("");
|
||||
|
||||
const handleAddTodo = () => {
|
||||
if (text.trim() === "") return;
|
||||
const newTodo: TodoItem = {
|
||||
id: todos.length + 1,
|
||||
text: text,
|
||||
completed: false,
|
||||
};
|
||||
const handleAddTodo = () => {
|
||||
if (text.trim() === "") return;
|
||||
const newTodo: TodoItem = {
|
||||
id: todos.length + 1,
|
||||
text: text,
|
||||
completed: false,
|
||||
};
|
||||
|
||||
setTodos([...todos, newTodo]);
|
||||
setText("");
|
||||
}
|
||||
setTodos([...todos, newTodo]);
|
||||
setText("");
|
||||
}
|
||||
|
||||
const handleToggleTodo = (id: number) => {
|
||||
const updatedTodos = todos.map((todo) => {
|
||||
if (todo.id === id) {
|
||||
return { ...todo, completed: !todo.completed };
|
||||
}
|
||||
return todo;
|
||||
});
|
||||
const handleToggleTodo = (id: number) => {
|
||||
const updatedTodos = todos.map((todo) => {
|
||||
if (todo.id === id) {
|
||||
return {...todo, completed: !todo.completed};
|
||||
}
|
||||
return todo;
|
||||
});
|
||||
|
||||
setTodos(updatedTodos);
|
||||
}
|
||||
setTodos(updatedTodos);
|
||||
}
|
||||
|
||||
const handleDeleteTodo = (id: number) => {
|
||||
const updatedTodos = todos.filter((todo) => todo.id !== id);
|
||||
setTodos(updatedTodos);
|
||||
}
|
||||
const handleDeleteTodo = (id: number) => {
|
||||
const updatedTodos = todos.filter((todo) => todo.id !== id);
|
||||
setTodos(updatedTodos);
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1>Todo List</h1>
|
||||
<input
|
||||
type="text"
|
||||
value={text}
|
||||
onChange={(e) => setText(e.target.value)}
|
||||
/>
|
||||
<button onClick={handleAddTodo}>Add Todo</button>
|
||||
<ul>
|
||||
{todos.map((todo) => (
|
||||
<Todo
|
||||
key={todo.id}
|
||||
id={todo.id}
|
||||
text={todo.text}
|
||||
completed={todo.completed}
|
||||
onToggle={handleToggleTodo}
|
||||
onDelete={handleDeleteTodo}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
return (
|
||||
<div>
|
||||
<h1>Todo List</h1>
|
||||
<input
|
||||
type="text"
|
||||
value={text}
|
||||
onChange={(e) => setText(e.target.value)}
|
||||
/>
|
||||
<button onClick={handleAddTodo}>Add Todo</button>
|
||||
<ul>
|
||||
{todos.map((todo) => (
|
||||
<Todo
|
||||
key={todo.id}
|
||||
id={todo.id}
|
||||
text={todo.text}
|
||||
completed={todo.completed}
|
||||
onToggle={handleToggleTodo}
|
||||
onDelete={handleDeleteTodo}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
|
Loading…
x
Reference in New Issue
Block a user