Created
June 17, 2022 19:48
-
-
Save Blazing-Mike/a43165e06977de86fb51564545e065ad to your computer and use it in GitHub Desktop.
a simple counter in react
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 React, { useState } from 'react'; | |
import ReactDOM from 'react-dom'; | |
function Counter() { | |
const [count, setCount] = useState(0); | |
function increment(){ | |
setCount(count + 1) | |
} | |
return ( | |
<div id="mainArea"> | |
<p>button count: <span>{count}</span></p> | |
<button id="mainButton" onClick={increment}>Increase</button> | |
</div> | |
); | |
} | |
ReactDOM.render( | |
<Counter />, | |
document.getElementById('root') | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment