useState
We request React to create a state variable and give us a view on it as well as a dispatch method which allows to request state changes. It is up to React to account for such requests, update the state and trigger a new render.
initial value
useState<number>(0)
Get the reference and a dispatch method
const [count, setCount] = React.useState<number>(0)
call the dispatch method
In the simplest form, the dispatch method expects a raw value.
Alternatively, it expects a callback, which may read the current state value and derive a value from it.
setCount(1)
setCount((count) => count + 1)