Created
November 8, 2016 22:33
-
-
Save pcstout/035207b9f12ebc122638bf1338ba57b1 to your computer and use it in GitHub Desktop.
React example with all code in a single HTML file
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> | |
<script src="https://jspm.io/system@0.19.js"></script> | |
<script type="text/template" id="code"> | |
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
const Hello = ({name}) => <h1>Hello {name}!</h1>; | |
ReactDOM.render( | |
<Hello name={"Albert"}/>, | |
document.body.appendChild(document.createElement("div")) | |
); | |
</script> | |
</head> | |
<body> | |
<div id="container"></div> | |
<script type="text/javascript"> | |
(function () { | |
System.config({ | |
transpiler: 'babel', | |
babelOptions: {} | |
}); | |
const tag = document.querySelector('#code'), | |
code = tag.textContent; | |
System.define(System.normalizeSync('my-module'), code); | |
System.import('my-module').then((mod) => { | |
console.log('mod loaded:', mod); | |
}); | |
})(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment