DEV Community

Andi
Andi

Posted on • Edited on

State

State (useState)

State digunakan untuk data yang akan berubah secara dinamis

import {useState} from "react"

export default function App(){
 const [count, setCount] = useState(0)
 const clickAction = () => {
  setCount(count + 1)
 } 
 return(
  <div>
   <p>clicked {count}</p>
   <button onClick={clickAction}>click me</button>
  </div>
 )
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)