I am using React 16.8.3 with hooks, currently I want to type React.useState
type Mode = 'confirm' | 'deny'
type Option = Number | null
const [mode, setMode] = React.useState('confirm')
const [option, setOption] = React.useState(100)
With my current code, mode
is of type string
, when instead I want it of type Mode
. Same issue with Option
.
How to add type notation to React.useState
?