8000 Caitlyn and Anjula's Chat Log by atamang90 · Pull Request #45 · Ada-C18/react-chatlog · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Caitlyn and Anjula's Chat Log #45

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

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

Conversation

atamang90
Copy link

No description provided.

FrancescaFr pushed a commit to FrancescaFr/react-chatlog that referenced this pull request Dec 21, 2022
8000
props.onUpdateChatEntry(updatedChatEntry);
};

const heart = props.liked ? '❤️' : '🤍';

Choose a reason for hiding this comment

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

Nice job using the liked value coming from props to update the component display. There's no need to track this with local state, since any time we update the state (using the supplied callback) the component data will update, which we will receive through updated props.

const heart = props.liked ? '❤️' : '🤍';

return (
<div className="chat-entry local">

Choose a reason for hiding this comment

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

The optional alignment feature would require us to be able to pick whether to use the local or remote class here. If the App made note of the sender of the first message, and passed that down as a prop, such as localSender, then we could use that value and the value of the current message's sender to determine whether this was a local or remote message.

timeStamp: props.timeStamp,
liked: !props.liked,
};
props.onUpdateChatEntry(updatedChatEntry);

Choose a reason for hiding this comment

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

Nice use of your passed-in callback to allow parent-owned logic to run when the like button is clicked.

<section className="entry-bubble">
<p>{props.body}</p>
<p className="entry-time">
<TimeStamp time={props.timeStamp} />

Choose a reason for hiding this comment

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

Nice job utilizing the TimeStamp component provided!


const ChatLog = (props) => {
const chatEntries = props.entries.map((chatEntry, index) => {
return (

Choose a reason for hiding this comment

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

Nice job utilizing this map feature to iterate over the entries 👍🏾

liked={chatEntry.liked}
>
// every list needs a key identifier (not a prop)
key={index}

Choose a reason for hiding this comment

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

Great work!

Comment on lines +24 to +35
ChatLog.propTypes = {
entries: PropTypes.arrayOf(
PropTypes.shape({
id: PropTypes.number.isRequired,
sender: PropTypes.string.isRequired,
body: PropTypes.string.isRequired,
timeStamp: PropTypes.string.isRequired,
liked: PropTypes.bool.isRequired,
})
),
onUpdateChatEntry: PropTypes.func.isRequired,
};

Choose a reason for hiding this comment

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

😁👍🏾

Comment on lines +9 to +15
id={chatEntry.id}
sender={chatEntry.sender}
body={chatEntry.body}
timeStamp={chatEntry.timeStamp}
liked={chatEntry.liked}
>
// every list needs a key identifier (not a prop)

Choose a reason for hiding this comment

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

This would be a good place to add some sort of evev/odd split to account for which message should go on which side. You could use an odd prop, something like this:

odd={i % 2}

Comment on lines +22 to +29
const countAllLikes = (chatData) => {
return chatData.reduce((likeCount, message) => {
if (message.liked) {
likeCount += 1;
}
return likeCount;
}, 0);
};

Choose a reason for hiding this comment

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

This is an optimal approach to calculating the number of likes, great job 😁

// pass this function down to ChatEntry using props
// updates chatData based on the input
const updateChatEntry = (updatedChatEntry) => {
const messages = chatData.map((message) => {

Choose a reason for hiding this comment

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

Nice use of map to make the copy of our array so that React will see that the state has changed.

};

const countAllLikes = (chatData) => {
return chatData.reduce((likeCount, message) => {

Choose a reason for hiding this comment

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

Nice use of reduce 💯

Copy link
@ameerrah9 ameerrah9 left a comment

Choose a reason for hiding this comment

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

Great work, Anjula! 🥳

Thank you for your patience as we catch up on grading. Nice work getting situated with React. This project is green 🟢

Keep it up 💯

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.

3 participants
0