Last active
September 28, 2018 05:23
-
-
Save agoiabel/45cabd40c0be1d248ee582fd0ce85ea0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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