Skip to content

Conversation

@sanakakadan22
Copy link

No description provided.

Copy link

@yangashley yangashley left a 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.

Comment on lines +8 to +10
// console.log(chatMessages);

// const [likedMap, setLikedMap] = useState({})

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

Comment on lines +35 to +36
addLike: PropTypes.func,
removeLike: PropTypes.func,

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?

Comment on lines +39 to +41
liked: PropTypes.bool,
addLike: PropTypes.func,
removeLike: PropTypes.func,

Choose a reason for hiding this comment

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

are these 3 required?

Comment on lines +13 to +14
const addLike = () => setLikedCount(likedCount + 1);
const removeLike = () => setLikedCount(likedCount - 1);

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 }

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

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