Skip to content

Instantly share code, notes, and snippets.

@jgierer12
Created January 27, 2018 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgierer12/ca0f1001fa2a0920f892fa754e600653 to your computer and use it in GitHub Desktop.
Save jgierer12/ca0f1001fa2a0920f892fa754e600653 to your computer and use it in GitHub Desktop.
Try it online! codepan.net/gist/ca0f1001fa2a0920f892fa754e600653
{
"showPans": [
"js",
"output"
],
"activePan": "js"
}
<script src="https://unpkg.com/preact@7.2.1/dist/preact.js"></script>
/* @jsx h */
const { Component, h, render } = preact
class App extends Component {
state = {
count: 0
}
inc = () => this.setState({
count: this.state.count + 1
})
dec = () => this.setState({
count: this.state.count - 1
})
render() {
return (
<div>
<h2>{ this.state.count }</h2>
<button onClick={this.inc}>Increment</button>
<button onClick={this.dec}>Decrement</button>
</div>
)
}
}
render(<App />, document.body)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment