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:
parent
c000f6af2d
commit
6b44610079
|
|
@ -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>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue