Conversation
kendallatada
left a comment
There was a problem hiding this comment.
Hi Ada! Your submission has been scored as green. You can find my comments in your code. Let me know if you have any questions. Nice work! 🥳
| if (entry.id === id) { | ||
| entry.liked = !entry.liked; | ||
| if (entry.liked) { | ||
| likeCount += 1; |
There was a problem hiding this comment.
Careful not to update the state variable directly! This could have unintended side effects. You should always use the setState() (or in this case setLikes()) function.
Here's a good discussion on this: https://stackoverflow.com/questions/37755997/why-cant-i-directly-modify-a-components-state-really
Alsoooo your app currently only increases likeCount and it doesn't handle situations where someone unlikes a message. I don't think this was explicitly stated as a requirement for the project, but I'm mentioning it since it is still good to pay attention to stuff like this.
|
|
||
|
|
||
| const ChatLog = (props) => { | ||
| const chatComponents = props.entries.map((entry) => { |
| let [likeCount, setLikes] = useState(0); | ||
|
|
||
| const changeHeartColor = (id) => { | ||
| const newEntries = entries.map((entry) => ({...entry})); |
There was a problem hiding this comment.
Nice copy! As a heads up, you can create a copy with Destructuring alone like this:
const newEntries = [...entries];
| <button className="like">🤍</button> | ||
| <p>{props.body}</p> | ||
| <TimeStamp className="entry-time" time={props.timeStamp}></TimeStamp> | ||
| <button className="like" onClick={heartToggle}>{props.liked ? '❤️' : '🤍' }</button> |
No description provided.