useState
We request React to create a state variable and give us a view on it as well as a dispatch method, which allows us to request state changes. It is up to React to account for such requests and potentially update the document
initial value
useState<number>(0)
receive 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.
setCount(1)
If we want to derive a value from the state, we may either refer to the state value we have in scope, or otherwise a state value given as part of a callback function.
setCount(count + 1)
setCount((count) => count + 1)