Skip to content

Commit f5ca9eb

Browse files
authored
Merge pull request #10 from jasanst/patch-2
Update README.md
2 parents e3b07b0 + 592e5e6 commit f5ca9eb

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ class App extends React.Component<{
147147
);
148148
}
149149
increment = (amt: number) => { // like this
150-
this.setState({
151-
count: this.state.count + amt
152-
});
150+
this.setState(state => ({
151+
count: state.count + amt
152+
}));
153153
}
154154
}
155155
```
@@ -422,9 +422,9 @@ class App extends React.Component<{}, {
422422
);
423423
}
424424
increment = (amt: number) => {
425-
this.setState({
426-
count: this.state.count + amt
427-
});
425+
this.setState(state => ({
426+
count: (state.count || 0) + amt
427+
}));
428428
}
429429
}
430430
```

0 commit comments

Comments
 (0)