Created
January 10, 2023 13:23
-
-
Save jabed-web-dev/f87677228c12a9389c342b3cfe5997a3 to your computer and use it in GitHub Desktop.
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 characters
| import { useState } from 'react' | |
| export default function ReactApp() { | |
| const [count, setCount] = useState(0) | |
| function handleClick() { | |
| setCount(count + 1) | |
| } | |
| return <button onClick={handleClick}>Clicked {`${count}`} times</button> | |
| } | |
| ;(function MyApp () { | |
| const root = document.getElementById('my-root') | |
| const button = document.createElement('button') | |
| let count = 0 | |
| button.addEventListener('click', () => { | |
| count += 1 | |
| button.childNodes[1].data = count | |
| }) | |
| button.append('Clicked ', count, ' times') | |
| root.appendChild(button) | |
| })() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment