Skip to content

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;

constructor(){
constructor() {
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