Last active
July 23, 2023 03:48
-
-
Save Badestrand/641a22bfcdce66a65d5a07d518237507 to your computer and use it in GitHub Desktop.
Simple preact in browser
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title></title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<style rel="stylesheet" type="text/less"> | |
* { | |
margin: 0; | |
padding: 0; | |
box-sizing: border-box; | |
} | |
main { | |
width: 800px; | |
margin: 50px auto; | |
} | |
</style> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/less.js/2.5.3/less.min.js"></script> | |
</head> | |
<body> | |
<div id="app"></div> | |
<script src="https://unpkg.com/preact@latest/dist/preact.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.24/browser.min.js"></script> | |
<script type="text/babel"> | |
const React = preact | |
class App extends preact.Component { | |
render() { | |
return ( | |
<main> | |
<h1>Hello!</h1> | |
</main> | |
) | |
} | |
} | |
preact.render(<App/>, document.getElementById('app')) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment