Skip to content

Instantly share code, notes, and snippets.

@jabed-web-dev
Created January 10, 2023 13:23
Show Gist options
  • Select an option

  • Save jabed-web-dev/f87677228c12a9389c342b3cfe5997a3 to your computer and use it in GitHub Desktop.

Select an option

Save jabed-web-dev/f87677228c12a9389c342b3cfe5997a3 to your computer and use it in GitHub Desktop.
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