Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

C17 Otters - Ada Barries #104

wants to merge 4 commits into from

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