Skip to content
Myr

Merge pull request #104 from mikollo/patch-1

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

Set state example correction

authored by Michel Weststrate · committed by GitHub · parents c589ddd, c0b5cc5 · 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