-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
todo app final part #781
base: master
Are you sure you want to change the base?
todo app final part #781
Conversation
src/TodoContext.tsx
Outdated
@@ -0,0 +1,92 @@ | |||
/* eslint-disable @typescript-eslint/no-unused-vars */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need unused-vars
?
src/components/Header/Header.tsx
Outdated
const sortAllInSelect = todos.filter(({ completed }) => !completed); | ||
|
||
preparedList = sortAllInSelect.map(item => { | ||
return { ...item, completed: true }; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can combine map and filter with using method reduce
src/components/Todo/Todo.tsx
Outdated
if (updatedTitle) { | ||
updatedTodo = { ...todo, title: updatedTitle }; | ||
} else { | ||
updatedTodo = { ...todo, completed: !completed }; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sense to use ternary operator here as it will make a code shorter
src/components/Todo/Todo.tsx
Outdated
setTodos(currentTodos => { | ||
const newTodos = [...currentTodos]; | ||
const index = newTodos.findIndex(item => item.id === updatedTodo.id); | ||
|
||
newTodos.splice(index, 1, updatedTodo); | ||
|
||
return newTodos; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you use method filter here and it will make a code shorter
src/components/Todo/Todo.tsx
Outdated
setIsLoading(false); | ||
setIsEditMode(false); | ||
} catch { | ||
setIsLoading(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/components/Todo/Todo.tsx
Outdated
)} | ||
|
||
<div className={cn('modal overlay', { | ||
'is-active': isLoading || selectedAreDeleting(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please don't call a function from the template because it will be executed every time when the state change, so make sense to move it to the variable
src/components/TodoList/TodoList.tsx
Outdated
<span className="todo__title">{tempTodo.title}</span> | ||
<button type="button" className="todo__remove">×</button> | ||
|
||
{/* 'is-active' class puts this modal on top of the todo */} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove all comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
DEMO LINK