diff --git a/src/App.tsx b/src/App.tsx index e005ee3e4..4ab4db298 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -95,16 +95,18 @@ export const App: React.FC = () => { const handleDeleteTodo = async (todoId: number) => { setIsLoading(curr => [...curr, todoId]); - deleteTodo(todoId) + return deleteTodo(todoId) .then(() => setTodos(currentTodos => currentTodos.filter(todo => todo.id !== todoId), ), ) - .catch(() => setError(errorMessages.delete)) + .catch(() => { + setError(errorMessages.delete); + throw new Error('not deleted'); + }) .finally(() => { setIsLoading(curr => curr.filter(delTodoId => delTodoId !== todoId)); - inputRef.current?.focus(); }); }; diff --git a/src/components/TodoItem.tsx b/src/components/TodoItem.tsx index 5232e3cff..f3fe355fd 100644 --- a/src/components/TodoItem.tsx +++ b/src/components/TodoItem.tsx @@ -4,7 +4,7 @@ import { Todo } from '../types/Todo'; interface Props { todo: Todo; - onRemoveTodo?: (todoId: number) => Promise; + onRemoveTodo?: (todoId: number) => void; onToggleTodoCompletion?: (todo: Todo) => void; onUpdateTodoTitle?: (todo: Todo) => Promise; isLoading: boolean;