Skip to content

Instantly share code, notes, and snippets.

Created Aug 18, 2021
What would you like to do?
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="component-goes-here"></div>
<!-- Load React. -->
<!-- Note: when deploying, replace "development.js" with "production.min.js". -->
<script src="" crossorigin></script>
<script src="" crossorigin></script>
<!-- Load your React component. -->
<script src="like_button.js"></script>
'use strict';
function LikeButton() {
const [liked, setLiked] = React.useState(false);
if (liked) {
return 'You liked this!';
return React.createElement(
onClick: () => setLiked(true),
const domContainer = document.getElementById('component-goes-here');
ReactDOM.render(React.createElement(LikeButton), domContainer);
Copy link

rachelnabors commented Aug 18, 2021

Adding JSX?

This example shows React without JSX. To add JSX, check out the official docs:

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