-
-
Save daylightnanalog/a85a2911d206f8c3b07404a0936f7134 to your computer and use it in GitHub Desktop.
Revisions
-
gaearon revised this gist
Apr 27, 2022 . 2 changed files with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -15,8 +15,8 @@ <h2>Add React in One Minute</h2> <!-- 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> This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -22,4 +22,5 @@ class LikeButton extends React.Component { } const domContainer = document.querySelector('#like_button_container'); const root = ReactDOM.createRoot(domContainer); root.render(e(LikeButton)); -
gaearon revised this gist
Oct 20, 2020 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -15,8 +15,8 @@ <h2>Add React in One Minute</h2> <!-- Load React. --> <!-- Note: when deploying, replace "development.js" with "production.min.js". --> <script src="https://unpkg.com/react@17/umd/react.development.js" crossorigin></script> <script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js" crossorigin></script> <!-- Load our React component. --> <script src="like_button.js"></script> -
gaearon revised this gist
Jun 25, 2018 . 2 changed files with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ <h2>Add React in One Minute</h2> <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". --> This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -21,5 +21,5 @@ class LikeButton extends React.Component { } } const domContainer = document.querySelector('#like_button_container'); ReactDOM.render(e(LikeButton), domContainer); -
gaearon revised this gist
Jun 25, 2018 . 1 changed file with 1 addition and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -21,8 +21,5 @@ class LikeButton extends React.Component { } } const domContainer = document.querySelector('.like_button_container'); ReactDOM.render(e(LikeButton), domContainer); -
gaearon revised this gist
Jun 25, 2018 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,7 @@ 'use strict'; const e = React.createElement; class LikeButton extends React.Component { constructor(props) { super(props); @@ -11,7 +13,7 @@ class LikeButton extends React.Component { return 'You liked this.'; } return e( 'button', { onClick: () => this.setState({ liked: true }) }, 'Like' @@ -23,4 +25,4 @@ class LikeButton extends React.Component { let domContainer = document.querySelector('.like_button_container'); // Show the LikeButton component inside our DOM container. ReactDOM.render(e(LikeButton), domContainer); -
gaearon revised this gist
Jun 25, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ <h2>Add React in One Minute</h2> <div class="like_button_container"></div> <!-- Load React. --> <!-- Note: when deploying, replace "development.js" with "production.min.js". --> <script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script> <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script> -
gaearon revised this gist
Jun 25, 2018 . 1 changed file with 3 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,28 +1,19 @@ 'use strict'; class LikeButton extends React.Component { constructor(props) { super(props); this.state = { liked: false }; } render() { if (this.state.liked) { return 'You liked this.'; } return React.createElement( 'button', { onClick: () => this.setState({ liked: true }) }, 'Like' ); } @@ -32,4 +23,4 @@ class LikeButton extends React.Component { let domContainer = document.querySelector('.like_button_container'); // Show the LikeButton component inside our DOM container. ReactDOM.render(React.createElement(LikeButton), domContainer); -
gaearon revised this gist
Jun 25, 2018 . 1 changed file with 1 addition and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -32,7 +32,4 @@ class LikeButton extends React.Component { let domContainer = document.querySelector('.like_button_container'); // Show the LikeButton component inside our DOM container. ReactDOM.render(React.createElement(LikeButton), domContainer); -
gaearon revised this gist
Jun 25, 2018 . 2 changed files with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ <h2>Add React in One Minute</h2> <p>React is loaded as a script tag.</p> <!-- We will put our React component inside this div. --> <div class="like_button_container"></div> <!-- Load React. --> <!-- Change .development.js to .production.min.js in both tags before deployment! --> This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -29,7 +29,7 @@ class LikeButton extends React.Component { } // Find the DOM container we defined in HTML. let domContainer = document.querySelector('.like_button_container'); // Show the LikeButton component inside our DOM container. ReactDOM.render( -
gaearon created this gist
Jun 25, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title>Add React in One Minute</title> </head> <body> <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 class="like_button_root"></div> <!-- Load React. --> <!-- Change .development.js to .production.min.js in both tags before deployment! --> <script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script> <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script> <!-- Load our React component. --> <script src="like_button.js"></script> </body> </html> This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ 'use strict'; // Define a LikeButton component class LikeButton extends React.Component { constructor(props) { super(props); // At first, the user didn't click "Like" this.state = { liked: false }; } render() { // If the user clicked "Like", show a message if (this.state.liked) { return 'You liked this.'; } // Otherwise, show the "Like" button return React.createElement( 'button', // This can be any DOM tag, try changing it to 'h1' { // This object contains button's "props" (short for properties). // They may be DOM attributes or event handlers. onClick: () => this.setState({ liked: true }) }, // Put any content here! 'Like' ); } } // Find the DOM container we defined in HTML. let domContainer = document.querySelector('.like_button_root'); // Show the LikeButton component inside our DOM container. ReactDOM.render( React.createElement(LikeButton), domContainer );