<html>
<head></head>
<body>
<div id="root"></div
</body>
</html>
body {
margin:0;
text-align:center;
font-size: 30px;
}
button {
font-size:30px;
}
const App = () => {
const [count, setCount] = React.useState(0)
const [countEffect, setCountEffect] = React.useState(0)
React.useEffect(() => {
setCountEffect((currentCount) => currentCount+1)
},[count])
return(
<>
<p>count(useState): {count}</p>
<p>count(useEffect): {countEffect}</p>
<button onClick={() => setCount((currentCount) => currentCount+1)}>Add</button>
<button onClick={() => setCount(() => 0)}>RESET</button>
</>
)
}
ReactDOM.render(
<App />,
document.getElementById('root')
)
View Compiled
This Pen doesn't use any external CSS resources.