Skip to content

Conversation

@DanGRT
Copy link

@DanGRT DanGRT commented Oct 7, 2018

No description provided.

const stockArray = currentStock ? JSON.parse(currentStock) : [];
const currentFaves = window.localStorage.getItem('favourites')
const favesArray = currentFaves ? JSON.parse(currentFaves) : [];
this.setState({
Copy link
Contributor

Choose a reason for hiding this comment

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

minor point, if you rename stockArray to stock and favesArray to faves you can shorten setState call to

this.setState({stock, favourites});

}

retrievePage(page){
this.setState({
Copy link
Contributor

Choose a reason for hiding this comment

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

nice

}

removeItem(ingredient, property){
let newList;
Copy link
Contributor

Choose a reason for hiding this comment

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

Since ternaries return a value, it would be better to perform a single assignment using the output

    const newList = property !== 'favourites'
      ?  this.state[property].filter(item => item.key !== ingredient.key)
      :  this.state[property].filter(item => item.recipe.uri !== ingredient.recipe.uri)

fetchRecipes(page = 0){
const searchString = this.state.activeIngredients.map(item => item.ingredient)
.join(",")
this.setState({
Copy link
Contributor

Choose a reason for hiding this comment

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

nice

@dmitrigrabov
Copy link
Contributor

Great work

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