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

react_dynamic_list_off_todos #2574

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

Conversation

VyacheslavKokayko
Copy link

Copy link

@volodymyr-soltys97 volodymyr-soltys97 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 make your code better

Comment on lines +31 to +45
<tr
key={todo.id}
data-cy="todo"
className={
selectedTodo?.id === todo.id ? 'has-background-info-light' : ''
}
>
<td className="is-vcentered">{todo.id}</td>
<td className="is-vcentered">
{todo.completed && (
<span className="icon" data-cy="iconCompleted">
<i className="fas fa-check" />
</span>
)}
</td>

Choose a reason for hiding this comment

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

Move this logic to the TodoItem component

key={todo.id}
data-cy="todo"
className={
selectedTodo?.id === todo.id ? 'has-background-info-light' : ''

Choose a reason for hiding this comment

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

Use the classnames library for add classes with condition, fix it everywhere

todo.completed ? 'has-text-success' : 'has-text-danger'
}
>
{todo.title}

Choose a reason for hiding this comment

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

Use destructuring for todo

data-cy="selectButton"
className="button"
type="button"
onClick={() => onSelect(todo)} // Викликаємо onSelect для вибору

Choose a reason for hiding this comment

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

Redundant

Suggested change
onClick={() => onSelect(todo)} // Викликаємо onSelect для вибору
onClick={() => onSelect(todo)}

getUser(userId)
.then(setSelectedUser)
.finally(() => setLoading(false));
}, [id, title, completed, userId]);

Choose a reason for hiding this comment

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

Suggested change
}, [id, title, completed, userId]);
}, [userId]);

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