Cannot add new data to state that contains an array – Reactjs
I have: [state, setState] = useState([ { item: apple, color: red, },{ item: banana, color:yellow, }]) I want to add the following to the array : { item: grape, color: purple } I have tried setState((prevState) => ({ ...prevState, newObj…