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

David Gridley DeliverEat #17

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

DavidGridley
Copy link

No description provided.

addOrder(incomingOrder) {
let nextId;
const orderIds = Object.keys(order);
orderIds.length === 0
Copy link
Contributor

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);
Copy link
Contributor

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") {
Copy link
Contributor

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))
Copy link
Contributor

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

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