Imagine that we need to update some property inside a object in state. Also we need to keep other properties intact.
const [myState,setMyState] = React.useState({propA: 'FOO'})
I usually do something like this:
function update() {
setMyState((prevState) => {
// IS 'prevState' A SHALLOW COPY OR A DIRECT REFERENCE TO THE SAME OBJECT
});
}
QUESTION
Is prevState a shallow copy or a direct reference to the same object? If it's a direct reference, is basically the very same object, right?