-
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
solution #1559
base: master
Are you sure you want to change the base?
solution #1559
Conversation
const activeTodosCount = useMemo( | ||
() => todos.filter(todo => !todo.completed).length, | ||
[todos], | ||
); | ||
const completedTodosCount = useMemo( | ||
() => todos.filter(todo => todo.completed).length, | ||
[todos], | ||
); | ||
const areAllTodosCompleted = useMemo( | ||
() => todos.every(todo => todo.completed), | ||
[todos], | ||
); |
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.
these three functions will work without useMemo, but they are also very good there
placeholder="What needs to be done?" | ||
ref={inputRef} | ||
value={inputValue} | ||
onChange={event => setInputValue(event.target.value)} |
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.
put it in a separate function
className="todo__title-field" | ||
placeholder="Empty todo will be deleted" | ||
value={todoTitleValue} | ||
onChange={event => setTodoTitleValue(event.target.value)} |
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.
also create separate function
tempTodo: Todo | null; | ||
loadingTodoIds: number[]; | ||
onRemoveTodo: (todoId: number) => Promise<void>; | ||
onUpdateTodo: (todo: Todo) => Promise<void>; |
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 sould change all functions that start with "on"
exmaple:
onUpdateTodo: (todo: Todo) => Promise<void>;
to
handleUpdateTodo: (todo: Todo) => Promise<void>;
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 sould change all functions that start with "on"
exmaple:
onUpdateTodo: (todo: Todo) => Promise<void>;
tohandleUpdateTodo: (todo: Todo) => Promise<void>;
No, when you pass handlers as props they should start from on
https://javascript.plainenglish.io/handy-naming-conventions-for-event-handler-functions-props-in-react-fc1cbb791364
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.
Good job, can you fix some comments and also 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.
Good work 👍
src/App.tsx
Outdated
if (filterStatus === FilterStatus.All) { | ||
return 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 don't need to filter at all when filterStatus === FilterStatus.All
tempTodo: Todo | null; | ||
loadingTodoIds: number[]; | ||
onRemoveTodo: (todoId: number) => Promise<void>; | ||
onUpdateTodo: (todo: Todo) => Promise<void>; |
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 sould change all functions that start with "on"
exmaple:
onUpdateTodo: (todo: Todo) => Promise<void>;
tohandleUpdateTodo: (todo: Todo) => Promise<void>;
No, when you pass handlers as props they should start from on
https://javascript.plainenglish.io/handy-naming-conventions-for-event-handler-functions-props-in-react-fc1cbb791364
DEMO LINK