Skip to content

Commit b17e11c

Browse files
committed
「React」の節のToDoリストの編集のサンプルプログラムのタイポを修正
1 parent 88aa4f5 commit b17e11c

File tree

1 file changed

+7
-7
lines changed
  • docs/4-advanced/04-react/_samples/todo-edit/src

1 file changed

+7
-7
lines changed

docs/4-advanced/04-react/_samples/todo-edit/src/App.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default function App() {
66
const [todos, setTodos] = useState<Todo[]>([]);
77
const [nextId, setNextId] = useState<number>(1);
88
const [newTodo, setNewTodo] = useState<string>("");
9-
const [edittingTodo, setEdittingTodo] = useState<Todo>({ id: -1, title: "" });
9+
const [editingTodo, setEditingTodo] = useState<Todo>({ id: -1, title: "" });
1010

1111
const addTodo = () => {
1212
setTodos([...todos, { id: nextId, title: newTodo }]);
@@ -35,27 +35,27 @@ export default function App() {
3535
};
3636

3737
const editTodo = (todo: Todo) => {
38-
setEdittingTodo(todo);
38+
setEditingTodo(todo);
3939
};
4040

4141
const fixTodo = () => {
4242
setTodos(
43-
todos.map((todo) => (todo.id === edittingTodo.id ? edittingTodo : todo)),
43+
todos.map((todo) => (todo.id === editingTodo.id ? editingTodo : todo)),
4444
);
45-
setEdittingTodo({ id: -1, title: "" });
45+
setEditingTodo({ id: -1, title: "" });
4646
};
4747

4848
return (
4949
<>
5050
<ul>
5151
{todos.map((todo, i) => (
5252
<li key={todo.id}>
53-
{edittingTodo.id === todo.id ? (
53+
{editingTodo.id === todo.id ? (
5454
<>
5555
<input
56-
value={edittingTodo.title}
56+
value={editingTodo.title}
5757
onChange={(e) => {
58-
setEdittingTodo({ id: todo.id, title: e.target.value });
58+
setEditingTodo({ id: todo.id, title: e.target.value });
5959
}}
6060
/>
6161
<button

0 commit comments

Comments
 (0)