Hello, let’s say we have a component that has a state variable that is an array of objects:
const [arrayOfObjects, setArrayOfObjects] = useState([{}, {}…])
If we now want to add a new object to this array, should we copy arrayOfObjects in a shallow or deep way before doing useState(arrayOfObjectsCopyWithAddedObject)?
submitted by /u/3434235245653613
[link] [comments]