-
Notifications
You must be signed in to change notification settings - Fork 111
Sharks - Sana Pournaghshband #88
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
base: main
Are you sure you want to change the base?
Conversation
yangashley
left a comment
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.
Nice work practicing React! Let me know if you have any questions about the comments.
🟢 for react-chatlog
Side note - I encourage you to pratice making more frequent commits after small code changes. I see that your commit history has 1 commit, but making a bunch of small commits allows you to go revisit your code at specific points in your development which will help with debugging in the future.
| // console.log(chatMessages); | ||
|
|
||
| // const [likedMap, setLikedMap] = useState({}) |
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 unused, commented out code
| addLike: PropTypes.func, | ||
| removeLike: PropTypes.func, |
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.
Are these two functions required?
| liked: PropTypes.bool, | ||
| addLike: PropTypes.func, | ||
| removeLike: PropTypes.func, |
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.
are these 3 required?
| const addLike = () => setLikedCount(likedCount + 1); | ||
| const removeLike = () => setLikedCount(likedCount - 1); |
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.
Can you think of how you could combine the logic from addLike() and removeLike() into one method like updateLike()? The bodies of these 2 methods look very similar, the difference being + or - so maybe we can add some logic by passing in a boolean value
updateLike = isLiked => { // your logic in 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.
Another comment about updating likedCount state with setLikedCount. When state represents something like a counter, we need to depend on a state's previous value and increment the previous value.
setLikedCount(prevState => prevState + 1)
This video here does a great job explaining why
No description provided.