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.

Revisions

  1. jabed-web-dev created this gist Jan 10, 2023.
    25 changes: 25 additions & 0 deletions React vs JSDOM.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    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)
    })()