how to handle individual increase decrease option in a table in react js?

Viewed 27

I'm using a page where I can handle the quantity of any product. but how can I use increase or decrease function for individual products?

     <tbody>
             {
               newProducts.map(newProduct => {
                  return(
                         <tr key={newProduct._id}>
                             <td>{newProduct.name}</td>
                             <td>{count}</td>
                             <td><FontAwesomeIcon onClick={() => setCount(count + 1)} icon={faPlus}></FontAwesomeIcon></td>
                             <td><FontAwesomeIcon onClick={() => setCount(count - 1)} icon={faMinus}></FontAwesomeIcon></td>
                             <td> <FontAwesomeIcon onClick={() => handleDelete(newProduct._id)} icon={faRemove}></FontAwesomeIcon></td>
                          </tr>
                         )
                   })
            }
    </tbody>
0 Answers
Related