Skip to content
Myr

Set state example correction

Before adoption: this commit came in with the history the project adopted, so no landing records it.

I think the difference would be more clear with such example.

authored by Mikołaj · committed by GitHub · parent c589ddd · Browse files · 1 file+4 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+4 added−4 removed

  • other:+4 added−4 removed

1 file+4 added−4 removed

modified:readme.md+4 added-4 removed
145 unmodified lines
146/**147 * Classic React.setState with a deep merge148 */149onBirthDayClick1 = () => {150 this.setState({150 this.setState((prevState)=>({151 user: {152 ...this.state.user,153 age: this.state.user.age + 1152 ...prevState.user,153 age: prevState.user.age + 1154 }155 })155 }))156}157158/**159 * ...But, since setState accepts functions,
208 unmodified lines