-
Notifications
You must be signed in to change notification settings - Fork 111
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
C17 Otters - Ada Barries #104
base: main
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) => { |
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 ✨
let [likeCount, setLikes] = useState(0); | ||
|
||
const changeHeartColor = (id) => { | ||
const newEntries = entries.map((entry) => ({...entry})); |
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 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> |
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 ternary operator 🎉
No description provided.