notrab / react-use-cart

React hook library for managing cart state

Home Page:http://npm.im/react-use-cart

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Adding same items over multiple lines

zaeis opened this issue · comments

commented

Some items are being added as a new line instead of adding to the quantity and.
When I update the quantity of one on the cart list, it updates the other.

I have two pages, one main with all items, one with a search (array filter) to show some items.
On the main page, when I add the same item twice, it updates the quantity correctly and the quantity becomes 2.
On the search page, when I add the same item twice, I get two lines for the same item and the quantity of each line stays at 1.
I tried to see if the item was already in the basket with inCart, and it returns false, even though it is there.
I then checked to see if my array for the item was different, but both duplicate lines have the same array, so it's not like I'm adding a slightly different item each time.

There's also another effect of this.
If I add one or two items from the regular page, then add the same item from the search page I can only add the item once from the search page, any other addItem does nothing.

The code for both maps are the same, the only difference is that one is mapped from a filtered array, and the other is not. For the same item on either page, the array for the item itself is identical.

I'm not sure why this is happening.

commented

Was a personal mistake, made a typo. Sorry for any worry! Works flawlessly now.