Adding quantity in my reactjs ecommerce website basket


I was making an E-commerce website using react.
I added a few items in the cart and went to the cart page.
I made a counter to increase or decrease the number of items.

but when I click on the plus button quantity of all the products increases all together

	const [number, setNumber] = useState(1); //number of item

	const updateQuantity = (id, value) => { => === id) &&
			setNumber((prevState) => prevState + value);

      // this is part of other files return statement

      <div className='counter'>
      <button onClick={() => updateQuantity(id, -1)}>-</button>
      <button onClick={() => updateQuantity(id, 1)}>+</button>
      <button onClick={() => remove(id)} className='remove-item'>Remove Form Cart</button></div>

uniqueItemsInCart is the data for products in the cart which is in the same form as the data in API is. [ {…},{…}, …, {…} ]

This is the link to API data

Help me with this error

Where does id in JSX come from?
What is this line doing: => === id)?
On what condition setNumber in updateQuantity won’t be executed?
Why you posted only some random lines instead of something executable?

Nobody is gonna watch the code of 10 files everything is connected to each other and I already specified everything which is required

So where does id in JSX come from?

you won’t know if people will look at 10 files of code, unless your try sharing your github repo.

nonetheless, i think your map function created an array of every
try debugging and the value of [id, and], or console.log them to see if they have an array value

here is article about debugging: How to Debug JavaScript with your Browser’s Devtools (

here is article about map function: JavaScript Map – How to Use the JS .map() Function (Array Method) (

I hope that’s helpful :sweat_smile:

I wonder if you succeeded in debugging it, considering it’s been a while since you’ve created this thread. I agree with @Sboonny idea. Maybe I’m wrong, but I doubt it. In any case, I could reach some of my whiz friends and ask them for their opinion. I need to know if you still need help. Moreover, considering you’re a newbie in dealing with e-commerce platforms, I highly suggest you consider downloading any chrome extension for salesforce. I hope you’re doing great, and I’m keenly waiting for your reply. Cheers.

1 Like

Thank you for bring this to my attention💚. Although it hasn’t been confirmed, I will be optimistic and say he fixed it, so I am closing this.

If the issue isn’t fixed, feel free to open new topic