-
Notifications
You must be signed in to change notification settings - Fork 38
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
David Gridley DeliverEat #17
base: master
Are you sure you want to change the base?
Conversation
addOrder(incomingOrder) { | ||
let nextId; | ||
const orderIds = Object.keys(order); | ||
orderIds.length === 0 |
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.
ternary returns a value so it would be better to use
const nextId = orderIds.length === 0 ? 1 : Math.max(...orderIds) + 1;
super(); | ||
this.fetchMenu = this.fetchMenu.bind(this); |
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.
fetch menu always gets called as a method and does not need binding
} | ||
|
||
render(){ | ||
receivePageChange(id) { | ||
if (id === "menu") { |
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 could be shortened to
this.setState({
currentPage: id
});
orderTotal: totalPrice | ||
} | ||
}, | ||
() => localStorage.setItem("currentOrder", JSON.stringify(this.state.currentOrder)) |
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.
The callback can be avoided here, passing incomingOrder
to localStorage rather than waiting for setState to complete and inserting data into localStorage after
No description provided.