<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

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://unpkg.com/react@18/umd/react.development.js
  2. https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.1.0/umd/react-dom.production.min.js