Skip to main content
added 33 characters in body
Source Link
quine9997
  • 808
  • 7
  • 13

Write your script in the html page. Example index.html

https://pastebin.com/2y8C87SD

<head>
   <meta charset="UTF-8">
   <title>React + htm Demo</title>
   
   <script src="https://unpkg.com/[email protected]" crossorigin></script>
   <script src="https://unpkg.com/react@16/umd/react.production.min.js" crossorigin></script>
   <script src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js" crossorigin></script>
   
   <script type="module">
   const { createElement, useState } = React;
   const render = ReactDOM.render;
   const html = htm.bind(createElement);
   
   function ClickCounter() {
     const [count, setCount] = useState(0);
     
     return html`
       <div>
         <button onClick=${() => setCount(count + 1)}>
           Clicked ${count} times
         </button>
       </div>
     `;
   }
   
   render(html`<${ClickCounter}/>`, document.getElementById("App"));
   </script>
</head>

<body>
   <h1> React + htm Demo</h1>
   <div id="App"/>
</body> 

Source

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules

https://www.w3schools.com/js/js_modules.asp

https://javascript.info/modules-intro

https://www.sitepoint.com/using-es-modules/


Write your script in the html page. Example index.html

<head>
   <meta charset="UTF-8">
   <title>React + htm Demo</title>
   
   <script src="https://unpkg.com/[email protected]" crossorigin></script>
   <script src="https://unpkg.com/react@16/umd/react.production.min.js" crossorigin></script>
   <script src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js" crossorigin></script>
   
   <script type="module">
   const { createElement, useState } = React;
   const render = ReactDOM.render;
   const html = htm.bind(createElement);
   
   function ClickCounter() {
     const [count, setCount] = useState(0);
     
     return html`
       <div>
         <button onClick=${() => setCount(count + 1)}>
           Clicked ${count} times
         </button>
       </div>
     `;
   }
   
   render(html`<${ClickCounter}/>`, document.getElementById("App"));
   </script>
</head>

<body>
   <h1> React + htm Demo</h1>
   <div id="App"/>
</body> 

Source

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules

https://www.w3schools.com/js/js_modules.asp

https://javascript.info/modules-intro

https://www.sitepoint.com/using-es-modules/


Write your script in the html page. Example index.html

https://pastebin.com/2y8C87SD

<head>
   <meta charset="UTF-8">
   <title>React + htm Demo</title>
   
   <script src="https://unpkg.com/[email protected]" crossorigin></script>
   <script src="https://unpkg.com/react@16/umd/react.production.min.js" crossorigin></script>
   <script src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js" crossorigin></script>
   
   <script type="module">
   const { createElement, useState } = React;
   const render = ReactDOM.render;
   const html = htm.bind(createElement);
   
   function ClickCounter() {
     const [count, setCount] = useState(0);
     
     return html`
       <div>
         <button onClick=${() => setCount(count + 1)}>
           Clicked ${count} times
         </button>
       </div>
     `;
   }
   
   render(html`<${ClickCounter}/>`, document.getElementById("App"));
   </script>
</head>

<body>
   <h1> React + htm Demo</h1>
   <div id="App"/>
</body> 

Source

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules

https://www.w3schools.com/js/js_modules.asp

https://javascript.info/modules-intro

https://www.sitepoint.com/using-es-modules/


Source Link
quine9997
  • 808
  • 7
  • 13

Write your script in the html page. Example index.html

<head>
   <meta charset="UTF-8">
   <title>React + htm Demo</title>
   
   <script src="https://unpkg.com/[email protected]" crossorigin></script>
   <script src="https://unpkg.com/react@16/umd/react.production.min.js" crossorigin></script>
   <script src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js" crossorigin></script>
   
   <script type="module">
   const { createElement, useState } = React;
   const render = ReactDOM.render;
   const html = htm.bind(createElement);
   
   function ClickCounter() {
     const [count, setCount] = useState(0);
     
     return html`
       <div>
         <button onClick=${() => setCount(count + 1)}>
           Clicked ${count} times
         </button>
       </div>
     `;
   }
   
   render(html`<${ClickCounter}/>`, document.getElementById("App"));
   </script>
</head>

<body>
   <h1> React + htm Demo</h1>
   <div id="App"/>
</body> 

Source

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules

https://www.w3schools.com/js/js_modules.asp

https://javascript.info/modules-intro

https://www.sitepoint.com/using-es-modules/