-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Develop #1153
base: master
Are you sure you want to change the base?
Develop #1153
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
src/App.tsx
Outdated
setIsLoading(true); | ||
setPostLoadingFail(false); | ||
getPosts(selectedUser.id) | ||
.then(data => setPosts(data)) |
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.
.then(data => setPosts(data)) | |
.then(setPosts) |
src/App.tsx
Outdated
}, [selectedUser]); | ||
|
||
const showPostTost = | ||
posts.length === 0 && !isLoading && selectedUser && !postLoadingFail; |
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.
posts.length === 0 && !isLoading && selectedUser && !postLoadingFail; | |
!posts.length && !isLoading && selectedUser && !postLoadingFail; |
src/App.tsx
Outdated
|
||
<PostsList /> | ||
{posts.length > 0 && !isLoading && ( |
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.
{posts.length > 0 && !isLoading && ( | |
{!!posts.length && !isLoading && ( |
src/components/PostDetails.tsx
Outdated
</button> | ||
</div> | ||
deleteComment(commentId).catch(() => { | ||
// Опционально: можно добавить обработку ошибок для восстановления удалённого комментария |
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.
Comment must be on English
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.
I`m use chatgpt because i want to better understand how writing nice code and logic. However i know than it bad practice. maybe)
src/components/PostDetails.tsx
Outdated
> | ||
<div className="message-header"> | ||
<a href={`mailto:${comment.email}`} data-cy="CommentAuthor"> | ||
{comment.name} |
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 comment
src/components/PostDetails.tsx
Outdated
delete button | ||
</button> | ||
</div> | ||
{!isLoading && !isError && comments.length === 0 && ( |
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.
{!isLoading && !isError && comments.length === 0 && ( | |
{!isLoading && !isError && !comments.length && ( |
src/components/UserSelector.tsx
Outdated
onClick={() => { | ||
setSelectedUserState(user); | ||
setDropdownOpen(false); | ||
setSelectedUser(user); | ||
}} |
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 from jsx to the helper function and use it here
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.
Great work!
DEMO