Skip to content

Instantly share code, notes, and snippets.

@dapperAuteur
Created December 30, 2017 23:36
Show Gist options
  • Save dapperAuteur/de1145e3d515d03394705995b2ea0483 to your computer and use it in GitHub Desktop.
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
<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