how to setstate based on another state property react code example
Example 1: Updating an object with setState in React
this.setState(prevState => {
let jasper = Object.assign({}, prevState.jasper);
jasper.name = 'someothername';
return { jasper };
})
this.setState(prevState => ({
jasper: {
...prevState.jasper,
name: 'something'
}
}))
Example 2: can we add new state property using setstate in react
How to become a pro with React setState() in 10 minuteswww.freecodecamp.org › news › get-pro-with-react-set...