Align class event handler creation with React docs

This is small change to align example React app with current advised way of assigning
event handlers that are declared as ES6 class methods:
https://reactjs.org/docs/handling-events.html

Thanks!
This commit is contained in:
Peter Blazejewicz 2018-02-03 16:08:55 +01:00 committed by Steve Sanderson
parent c000f6af2d
commit 6b44610079
1 changed files with 2 additions and 1 deletions

View File

@ -6,6 +6,7 @@ export class Counter extends Component {
constructor() {
super();
this.state = { currentCount: 0 };
this.incrementCounter = this.incrementCounter.bind(this);
}
incrementCounter() {
@ -23,7 +24,7 @@ export class Counter extends Component {
<p>Current count: <strong>{this.state.currentCount}</strong></p>
<button onClick={() => this.incrementCounter()}>Increment</button>
<button onClick={this.incrementCounter}>Increment</button>
</div>
);
}