Skip to content

Alexandra Koren - week 3 submission#5

Open
sashako8 wants to merge 4 commits intofrontend-application-development-uw20:masterfrom
sashako8:master
Open

Alexandra Koren - week 3 submission#5
sashako8 wants to merge 4 commits intofrontend-application-development-uw20:masterfrom
sashako8:master

Conversation

@sashako8
Copy link

@sashako8 sashako8 commented May 1, 2020

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): 2
  • Completion rating on this assignment: complete

@sashako8 sashako8 changed the title uploading code for Tim Alexandra Koren - week 3 submission May 7, 2020
}
}

addItemToCart = (idx) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good 👍


removeItem = (idx) => {
return (e) => {
const totalCost = this.state.total - Airbnbs[idx].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.

Accessing Airbnbs[idx] causes the app to crash if more than 3 Airbnbs are added to the cart + the last Airbnb is removed. It can also result in incorrect payment costs to be subtracted. To fix this, you'll want to access this.state.cartItems[idx] instead, since the index refers to the cart array, not the airbnb array.

{airbnb.host.isSuperhost ? <p class="host">Is a Superhost: Yes</p> : null}
<p>Stars: {airbnb.rating.stars}</p>
<p>Reviews: {airbnb.rating.reviews}</p>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks great, all the data's there

isSuperhost: PropTypes.bool.isRequired,
stars: PropTypes.string.isRequired,
reviews: PropTypes.string.isRequired
})
Copy link
Contributor

Choose a reason for hiding this comment

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

These proptypes accurately describe the shape of an airbnb, but a few things:

  1. Since airbnbs is an array, you'll want to use Proptypes.arrayOf(PropTypes.shape(...)) to describe an array of objects.
  2. airbnbs isn't used as a prop in this component, so this could be moved to the ListingLayout component instead.

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