-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
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 job 👍
Let's make your code better
<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> |
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.
Move this logic to the TodoItem
component
key={todo.id} | ||
data-cy="todo" | ||
className={ | ||
selectedTodo?.id === todo.id ? 'has-background-info-light' : '' |
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.
Use the classnames library for add classes with condition, fix it everywhere
todo.completed ? 'has-text-success' : 'has-text-danger' | ||
} | ||
> | ||
{todo.title} |
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.
Use destructuring for todo
data-cy="selectButton" | ||
className="button" | ||
type="button" | ||
onClick={() => onSelect(todo)} // Викликаємо onSelect для вибору |
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.
Redundant
onClick={() => onSelect(todo)} // Викликаємо onSelect для вибору | |
onClick={() => onSelect(todo)} |
getUser(userId) | ||
.then(setSelectedUser) | ||
.finally(() => setLoading(false)); | ||
}, [id, title, completed, userId]); |
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.
}, [id, title, completed, userId]); | |
}, [userId]); |
DEMO LINK