Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@cpq
Last active July 16, 2019 14:40
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/886c9d66f58e95db1934d018e95b28f3 to your computer and use it in GitHub Desktop.
Save cpq/886c9d66f58e95db1934d018e95b28f3 to your computer and use it in GitHub Desktop.
minimal preact app with ES3 syntax
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://unpkg.com/preact"></script>
</head>
<body> </body>
<script>
var h = preact.h;
var App = function(props) {
var self = this;
self.componentDidMount = function() {
self.setState({cnt: 1});
};
var btn = h('button', {class: 'btn btn-danger mr-3', onClick: function() {
self.setState({cnt : self.state.cnt + 1});
}}, 'click me');
return h('div', {class:'jumbotron bg-warning m-5'}, btn, self.state.cnt);
};
preact.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