-
-
Save gaearon/779b12e05ffd5f51ffadd50b7ded5bc8 to your computer and use it in GitHub Desktop.
Adding multiple React components on a single HTML page
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8" /> | |
<title>Add Multiple React components on a single HTML page</title> | |
</head> | |
<body> | |
<h2>Add Multiple React components on a single HTML page</h2> | |
<p>This page demonstrates using React with no build tooling to add multiple components to a single page.</p> | |
<p>React is loaded as a script tag.</p> | |
<p> | |
This is the first comment. | |
<!-- We will put our React component inside this div. --> | |
<div class="like-button-root" data-commentid="1"></div> | |
</p> | |
<p> | |
This is the second comment. | |
<!-- We will put our React component inside this div. --> | |
<div class="like-button-root" data-commentid="2"></div> | |
</p> | |
<p> | |
This is the third comment. | |
<!-- We will put our React component inside this div. --> | |
<div class="like-button-root" data-commentid="3"></div> | |
</p> | |
<!-- Load React. --> | |
<!-- Note: when deploying, replace "development.js" with "production.min.js". --> | |
<script src="https://unpkg.com/react@18/umd/react.development.js" crossorigin></script> | |
<script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js" crossorigin></script> | |
<!-- Load our React component. --> | |
<script src="like_button.js"></script> | |
</body> | |
</html> |
Nbbn
Lnj
Ughj
Learn about createElement here: create element
Learn about passing props here: passing props
It would be helpful if <script src="like_button.js"></script> were changed to <script src="like-button.js"></script> for consistency with the new tutorial
Nice
Cool!
awesome, new documentation is really helpful
can someone explain, why don't we need keys here for different LikeButton elements in line 24?
oh, we are mounting them on different HTML nodes and not in same place, never mind!
I loved the new documentation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hfh