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

Sea Turtles/ Theresa Davis #100

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

Sea Turtles/ Theresa Davis #100

wants to merge 2 commits into from

Conversation

perugia33
Copy link

No description provided.

Copy link

@tgoslee tgoslee left a 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);
Copy link

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 => {
Copy link

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 = ()=>{
Copy link

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 = {
Copy link

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 =>(
Copy link

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}

Comment on lines +22 to +23
{/* Wave 01: Render one ChatEntry component
Wave 02: Render ChatLog component */}
Copy link

Choose a reason for hiding this comment

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

Suggested change
{/* Wave 01: Render one ChatEntry component
Wave 02: Render ChatLog component */}

); }

ChatLog.propTypes = {
chats:PropTypes.arrayOf(PropTypes.shape({
Copy link

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.

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