const [state, setState] = useState(initialState)
now you must call useState in the same order.
function example() {
const [ count, setCount ] = useState(0)
}
function App() {
const [ count, setCount ] = useState(0)
function handleChangeCount() {
setCount(1)
}
}
combining with EventHandler's
function App() {
const [ x, setX ] = useState("")
const [ y, setY ] = useState(0)
const handleMrFlibble = e => {
setX(e.target.textContent)
setY(y+1)
}
return (
<Main>
<MyButton onClick={handleMrFlibble}>Fry</MyButton>
</Main>
)
}