Skip to content

Instantly share code, notes, and snippets.

@RickWong
Last active December 22, 2020 13:37
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save RickWong/ad9cd9bd96884847cd05b352cb4e90e1 to your computer and use it in GitHub Desktop.
Save RickWong/ad9cd9bd96884847cd05b352cb4e90e1 to your computer and use it in GitHub Desktop.
React without Webpack
const App = ({name}) => {
return (
<h1>Hello {name}</h1>
);
};
ReactDOM.render(<App name="World" />, document.getElementById("App"));
<html>
<body>
<div id="App"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.0.1/react-with-addons.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.0.1/react-dom.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.7.7/babel.min.js"></script>
<script>
fetch("./app.js").then(function (response) {
response.text().then(function (js) {
eval(Babel.transform(js, {presets: ['es2015', 'react']}).code);
});
});
</script>
</body>
</html>
@RickWong
Copy link
Author

RickWong commented Apr 30, 2016

Here's a version with just one HTML file using text/template:
https://gist.github.com/RickWong/dd2a0aba86699ded4cc295d84601d540

It works better locally. (file:///index.html)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment