-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
todos with api task implementation #1959
base: master
Are you sure you want to change the base?
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.
Good work!
Don't overload a server-side)
src/App.tsx
Outdated
setVisibleTodos(filterTodos(todosFromServer, query, filter)); | ||
}) | ||
.finally(() => setLoading(false)); | ||
}, [filter, query]); |
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.
It is not necessary to request to the server within every new symbol or filter change, in this case.
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.
query, | ||
}) => { | ||
const handleFilterChange = (event: React.ChangeEvent<HTMLSelectElement>) => { | ||
const newFilterBy = event.target.value as FilterBy; |
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.
it looks like this variable is redundant, using only one time
src/components/TodoList/TodoList.tsx
Outdated
</tr> | ||
<tr | ||
data-cy="todo" | ||
className="" |
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 className
please
useEffect(() => { | ||
getUser(todoSelected.userId) | ||
.then((givenUser) => { | ||
setTodoUser(givenUser); | ||
}) | ||
.finally(() => setTodoLoading(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.
useEffect(() => { | |
getUser(todoSelected.userId) | |
.then((givenUser) => { | |
setTodoUser(givenUser); | |
}) | |
.finally(() => setTodoLoading(false)); | |
}); | |
useEffect(() => { | |
getUser(todoSelected.userId) | |
.then((givenUser) => { | |
setTodoUser(givenUser); | |
}) | |
.finally(() => setTodoLoading(false)); | |
}, []); |
let's add deps for useEffect
because now useEffect
will calling every time, please try to open modal and go to the network
look at requests
{todoSelected.completed | ||
? ( | ||
<strong className="has-text-success">Done</strong> | ||
) | ||
: ( | ||
<strong className="has-text-danger">Planned</strong> | ||
)} |
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.
we can use single strong
tag and only change success
to danger
and children
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
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 to me, i'm approving it!
Demo