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>
)
}
Top comments (0)