Skip to content

Conversation

@adabarries
Copy link

No description provided.

Copy link

@kendallatada kendallatada left a 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;

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) => {

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}));

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>

Choose a reason for hiding this comment

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

Nice ternary operator 🎉

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