Skip to content

Instantly share code, notes, and snippets.

Last active January 26, 2024 11:25
Star You must be signed in to star a gist
Save gaearon/6668a1f6986742109c00a581ce704605 to your computer and use it in GitHub Desktop.
Add React in One Minute
<!DOCTYPE html>
<meta charset="UTF-8" />
<title>Add React in One Minute</title>
<h2>Add React in One Minute</h2>
<p>This page demonstrates using React with no build tooling.</p>
<p>React is loaded as a script tag.</p>
<!-- We will put our React component inside this div. -->
<div id="like_button_container"></div>
<!-- Load React. -->
<!-- Note: when deploying, replace "development.js" with "production.min.js". -->
<script src="" crossorigin></script>
<script src="" crossorigin></script>
<!-- Load our React component. -->
<script src="like_button.js"></script>
'use strict';
const e = React.createElement;
class LikeButton extends React.Component {
constructor(props) {
this.state = { liked: false };
render() {
if (this.state.liked) {
return 'You liked this.';
return e(
{ onClick: () => this.setState({ liked: true }) },
const domContainer = document.querySelector('#like_button_container');
const root = ReactDOM.createRoot(domContainer);
Copy link


Copy link

onigetoc commented Sep 7, 2023

jsfiddle demo but without the js url component but direct inside the javascript:

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