I created the SelectProps interface!
export interface SelectProps {
value: string
options: string[]
onChange: (value: any) => void
}
I created react component!
<Select
value="red"
options={['dark', 'white']}
onChange={(value) => console.log(value)}
/>
How do I make value one of the values of options ('dark' | 'white') ? That is, I want to get this type:
type Value = 'dark' | 'white'
I must say right away this solution is not suitable:
const options = ['dark', 'white'] as const
type Value = typeof options[number]