I'm trying to type useState() hook which can get number and string type as its value.
export interface Select {
selectValue: React.Dispatch<React.SetStateAction<number | string>>;
...
}
And I'm trying to use above component like this,
const [value, setValue] = React.useState(0);
<Select selectValue = {setValue} />
But It gives me this Error.
Type 'Dispatch<SetStateAction<number>>' is not assignable to type 'Dispatch<SetStateAction<string | number>>'.
Type 'SetStateAction<string | number>' is not assignable to type 'SetStateAction<number>'.
Type 'string' is not assignable to type 'SetStateAction<number>'.
How can I resolve this Error?