I have a component like this
type inputProps = {
value: string | number | boolean
onChange: (arg: string | number | boolean) => void
}
const Input = ({value, onChange}: inputProps) => {
return <div />
}
const OtherComponent = () => {
const [value, setValue] = React.useState(5)
// onChange type not compatible
return <Input value={value} onChange={setValue} />
}
const AnotherComponent = () => {
const [value, setValue] = React.useState('Hey')
// onChange type not compatible
return <Input value={value} onChange={setValue} />
}
Is it possible to make the arg
of the onChange
function dependent on the value?