Skip to content

Week3-Assignment completed. #1

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 2 commits into
base: main
Choose a base branch
from

Conversation

ductran67
Copy link

Week 3 HW Submission

Please fill out the information below in order to complete your assignment. Feel free to update this comment later if necessary.

  • Comfort rating on this assignment (1-5): 3
  • Completion rating on this assignment: complete

const addItem = (id) => {
setItemList([...itemList, bnbs[id]]);
// Sum total cost
totalCost += bnbs[id].payment.cost;
Copy link
Contributor

Choose a reason for hiding this comment

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

While this works here, I would make sure that totalCost is stored within the component via useState. This will guarantee that changing the value will indeed re-render the component and display the right amount. In this case, it works, but it's possible for future changes to break this functionality.

item={item}
onRemove={() => removeItem(idx)}
/>
)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Great use of components for the rentals/cart.

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