Skip to content
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 #1054

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Solution #1054

wants to merge 1 commit into from

Conversation

0YehorVolkov0
Copy link

Copy link

@igorkruz igorkruz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good Job 👍
let's improve your solution

Comment on lines +16 to +25
setIsLoadingTodos(true);

getTodos()
.then((response: Todo[]) => {
dispatch(setTodos(response));
})
.catch(() => {
throw new Error("Can't get todos");
})
.finally(() => setIsLoadingTodos(false));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to move the logic inside the useEffect hook to a separate function, as it improves code readability, reusability, and makes testing easier. It also helps keep useEffect focused on side effects.

Comment on lines +19 to +28
useEffect(() => {
if (currentTodo) {
getUser(currentTodo.userId)
.then(setUser)
.catch(() => {
throw new Error("Can't get User information");
})
.finally(() => setIsLoading(false));
}
}, [currentTodo]);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to move the logic inside the useEffect hook to a separate function, as it improves code readability, reusability, and makes testing easier. It also helps keep useEffect focused on side effects.

Comment on lines +63 to +67
{currentTodo?.completed ? (
<strong className="has-text-success">Done</strong>
) : (
<strong className="has-text-danger">Planned</strong>
)}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can simplify this, you can render just one strong and show the text and add className according to the condition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants