How do I change the value of inCart to true based on id, like i have a function that will provide a id , and base that id i want to change the first objects inCart value to true or the 2nd object inCart value
I tried like this:
setInfo({ info[id].inCart: true })
/*Note: id is a parameter that hold the number like 1 or 2 etc*/
const [info, setInfo] = useState([
{
id: 1,
title: "Google Pixel - Black",
inCart: false
},
{
id: 2,
title: "Samsung S7",
inCart: false,
}
])
idininfo[id]refer to??Index or the id of Object