Updating objects in a State. How not to use spread operator.
Understanding state and mutating object.
To add interactivity, we use state in react, the UI changes only when the state changes, when you set a new state, not by mutating the state.
That's why you shouldn't change objects that you have stored in rea...
gauravv.hashnode.dev4 min read
GAURAV BURANDE
Web development
A dumb way to copy an object is using the spread operator.
Instead use JSON.parse(JSON.stringify(object)) or JS has a new global function for cloning, checkout structuredClone() developer.mozilla.org/en-US/docs/Web/API/structur…