Created
December 30, 2017 23:36
-
-
Save dapperAuteur/de1145e3d515d03394705995b2ea0483 to your computer and use it in GitHub Desktop.
Egghead.com The Beginner's Guide To ReactJS Tutorial: Use Class Components With React
This file contains 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
<script type="text/babel"> | |
class Counter extends React.Component { | |
constructor(...args) { | |
super(...args); | |
this.state = { count: 0 } | |
} | |
render() { | |
return ( | |
<button | |
onClick={ () => | |
this.setState(({ count }) => ({ | |
count: count + 1, | |
}))} | |
> | |
{ this.state.count } | |
</button> | |
) | |
} | |
} | |
ReactDOM.render( | |
<Counter />, | |
document.getElementById('root') | |
); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment