Skip to content

Instantly share code, notes, and snippets.

@agoiabel
Last active September 28, 2018 05:23
Show Gist options
  • Save agoiabel/45cabd40c0be1d248ee582fd0ce85ea0 to your computer and use it in GitHub Desktop.
Save agoiabel/45cabd40c0be1d248ee582fd0ce85ea0 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
class Counter extends Component {
constructor() {
super();
this.state = {
count: 0
}
}
increment = () => {
this.setState(prevState => {
return {
count: prevState.count + 1
}
});
}
render() {
<div>
<p data-test="test_result">Current Count: {this.state.count}</p>
<button data-test="increment_button" onClick={this.increment}>Increment Count</button>
</div>
}
}
export default Counter;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment