Advertisement
Guest User

Untitled

a guest
Aug 12th, 2023
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.91 KB | Source Code | 0 0
  1. <head>
  2.    <meta charset="UTF-8">
  3.    <title>React + htm Demo</title>
  4.    
  5.    <script src="https://unpkg.com/[email protected]" crossorigin></script>
  6.    <script src="https://unpkg.com/react@16/umd/react.production.min.js" crossorigin></script>
  7.    <script src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js" crossorigin></script>
  8.    
  9.    <script type="module">
  10.    const { createElement, useState } = React;
  11.    const render = ReactDOM.render;
  12.    const html = htm.bind(createElement);
  13.    
  14.    function ClickCounter() {
  15.      const [count, setCount] = useState(0);
  16.      
  17.      return html`
  18.        <div>
  19.          <button onClick=${() => setCount(count + 1)}>
  20.            Clicked ${count} times
  21.          </button>
  22.        </div>
  23.      `;
  24.    }
  25.    
  26.    render(html`<${ClickCounter}/>`, document.getElementById("App"));
  27.    </script>
  28. </head>
  29.  
  30. <body>
  31.    <h1> React + htm Demo</h1>
  32.    <div id="App"/>
  33. </body>
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement