-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
add task solution #741
base: master
Are you sure you want to change the base?
add task solution #741
Conversation
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.
Please check a couple comments.
src/TodoApp/TodoApp.tsx
Outdated
const isSomeComplete = todos.some(todo => todo.completed === true); | ||
const allCompleted = todos.every(todo => todo.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.
const isSomeComplete = todos.some(todo => todo.completed === true); | |
const allCompleted = todos.every(todo => todo.completed === true); | |
const isSomeComplete = todos.some(todo => todo.completed); | |
const allCompleted = todos.every(todo => todo.completed); |
redundant to compare two boolean values
also looks like redundant to make additional loop for isSomeCoplete.
we can compare length of todos and length of noCompleteTodos and will know whether we have some completed todos.
const isSomeComplete = noCompleteTodos.length !== todos.length;
onClick={() => { | ||
onFilterChange(Filter.ALL); | ||
}} |
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.
suggest to make one handler factory and use for each filter button.
const handleFilter = (filter: Filter) => () => onFilterChange(filter);
onClick={() => { | |
onFilterChange(Filter.ALL); | |
}} | |
onClick={handleFilter(Filter.ALL)} |
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.
Well done
DEMO LINK