Last active
July 16, 2019 14:40
-
-
Save cpq/886c9d66f58e95db1934d018e95b28f3 to your computer and use it in GitHub Desktop.
minimal preact app with ES3 syntax
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
<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