I have data object as
let d = {
'items': [
{'item':'apple', price: 200},
{'item':'banana', price: 300},
],
tot:[2],
'shop': 'xyx shop',
'customer':['a','b','c']
}
i am getting it from an api call and setting it to a state. Like this
const [state, setState] = useState({})
useEffect(
{
setState(d)
},[])
Here how can I update the price?
I have tried this
setState({...state, items[index].price - 1});
It's not working at all.