-
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
Sea Turtles/ Theresa Davis #100
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.
Great job Theresa! Let me know if you have any questions.
return ( | ||
<div id="App"> | ||
|
||
console.log(chatMessages); |
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.
remove this console log after debugging
function App () { | ||
|
||
const [chatData, setChatData] = useState(chatMessages) | ||
const updateChatData = updatedChat => { |
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.
this function looks good. You can remove the console log on line 15
setChatData(chats); | ||
}; | ||
|
||
const calcTotalHearts = ()=>{ |
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.
great way to use existing data to calculate total likes. You could also use reduce like
return messageData.reduce((totalLikes, message) => {
// If messages.liked is true add 1 to totalLikes, else add 0
return (totalLikes += message.liked ? 1 : 0);
}, 0); // The 0 here sets the initial value of totalLikes to 0
</div> | ||
); | ||
}; | ||
|
||
ChatEntry.propTypes = { |
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.
you don't have any prop types. Your test should be looking for prop types for sender, body and timeStamp
|
||
const ChatLog = (props) => { | ||
|
||
const chatDataMap = props.chats.map(item =>( |
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.
using item.id
as the key probably still gives you an error in Learn. You can get rid of this by using the index parameter for the map function like
const chatDataMap = props.chats.map((item, i) =>
<ChatEntry
key={i}
{/* Wave 01: Render one ChatEntry component | ||
Wave 02: Render ChatLog component */} |
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.
{/* Wave 01: Render one ChatEntry component | |
Wave 02: Render ChatLog component */} |
); } | ||
|
||
ChatLog.propTypes = { | ||
chats:PropTypes.arrayOf(PropTypes.shape({ |
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.
great use of shape. Make sure to only had isRequired to props that are a must for the component to render. If you want them all to be required then you should update the tests to reflect that.
No description provided.