My desired output will look like this
{'3afdrjke3j43kjkjf' : 3 , '8fsdfdsni3ni3dsfa' :2 }
I tried like this but it didn't work
const [productQuantity, setProductQuantity] = useState([]);
const handleQuantity = (e, id) => {
setProductQuantity({id : e.target.value}) // this outputs {id : "3"}
}
Whenever i trigger onchange event the id and and the quantity passed on the the handleQuantity function. Where i want to concat the key value pairs in to the state.
<Form.Control onChange={(e) => handleQuantity(e, cartProduct._id)} as="select">
{
[...Array(cartProduct.quantity)].map((_, index) =>{
return <option>{index + 1}</option>
})
}
</Form.Control>
Thanks in Advance :)