Skip to content

Week3 homework#6

Open
lanettecream wants to merge 1 commit into
modern-web-application-uw18:masterfrom
lanettecream:master
Open

Week3 homework#6
lanettecream wants to merge 1 commit into
modern-web-application-uw18:masterfrom
lanettecream:master

Conversation

@lanettecream

Copy link
Copy Markdown

My understanding: 3 out of 5. Please explain binding and sending state across components more
Complete: As complete as I can make it before the deadline.

Comment thread ecommerce-ui/src/App.js
};
}

addRoom = (room) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The easiest way to deal with binding functions is to use the arrow function syntax you used here only. By doing so, you shouldn't need to use this.addRoom = this.addRoom.bind(this), although the function will still behave the same because you're binding to the same context.

Comment thread ecommerce-ui/src/App.js
removeRoom = (room) => {
this.setState((prevState) => {
let rooms = prevState.rooms;
let filteredRooms = rooms.filter(item => item.title !== room.title);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice 👍 Ideally if the Airbnbs had ids, we could filter on those as well.


it('renders without crashing with props', () => {
const div = document.createElement('div');
ReactDOM.render(<Cart ={testArticle} type="article" />, div);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This ={testArticle} is causing a syntax error with your tests. The best way to test this is to create a fake props object above, then pass it into the Cart component. If you need to pass functions, you can use jest.fn() to create a mock function.

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