Skip to content

Instantly share code, notes, and snippets.

@cpq
Created November 1, 2019 22:31
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 cpq/52947accfbbc0a4bfe1c8ec6a7e5f3ff to your computer and use it in GitHub Desktop.
Save cpq/52947accfbbc0a4bfe1c8ec6a7e5f3ff to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<title>hiii</title>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://unpkg.com/bootstrap@4.3.1/dist/css/bootstrap.min.css" />
<script src="https://unpkg.com/preact@8.4.2"></script>
<script src="https://unpkg.com/htm@2.2.1"></script>
</head>
<body></body>
<script>
const {h, render, Component} = preact;
const html = htm.bind(h);
class App extends Component {
state = {counter: 0};
inc() {
this.setState({counter: this.state.counter + 1});
}
render() {
return html`
<div class="my-5 text-center">
<button class="btn btn-info px-5" onclick=${()=>{this.inc()}}>
${this.state.counter}
</button>
</div>
`
}
};
window.onload = () => render(h(App), document.body);
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment