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

Homew5 context bogdan mireanu #61

Open
wants to merge 7 commits into
base: bogdan-mireanu
Choose a base branch
from

Conversation

Bogdan-Mireanu
Copy link
Collaborator

mi-am prins urechile in functia addToWishlist, nu am reusit sa o fac sa mearga pentru fiecare itemid si nu pentru toate la click

Copy link
Owner

@speedy4all speedy4all left a comment

Choose a reason for hiding this comment

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

Ok, e bine pentru inceput

}

addToWishlist = (bookId) => {
const bookWishlist = this.state.bookList.find(item => item.id === bookId);
Copy link
Owner

Choose a reason for hiding this comment

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

Pai fiecare carte ar trebui sa contina o proprietate numita cum vrei tu, poate wishListed, de tip boolean, iar cand dai click pe butonul unei carti, schimbi doar valoarea acelei proprietati. Ceva de genul:

const newBooks = this.state.bookList.map(book => {
      if(book.id === bookId) {
           book.wishListed = !book.wishListed;
      }
      return book;
});
this.setState({bookList: newBooks});

</div>);
if (this.state.loader1 && !this.state.loader2)
return (
<WishlistContext.Provider value={{wishlist:this.state.wishlist}}>
Copy link
Owner

Choose a reason for hiding this comment

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

Nu prea vad nevoia acestui context

Suggested change
<WishlistContext.Provider value={{wishlist:this.state.wishlist}}>
<WishlistContext.Provider value={{wishlist:this.state.wishlist}}>

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.

3 participants