using react-responsive-select with formik+typescript
I'm currently facing an issue trying to use react-responsive-select with formik and typescript.
This is how i'm using it:
`
<Select
name="tipo"
modalCloseButton={<ModalCloseButton />}
options={[
{ value: 'C', text: 'Clienti' },
{ value: 'F', text: 'Fornitori' },
{ value: 'V', text: 'Vettori' },
{ value: 'R', text: 'Referenti' },
{ value: 'A', text: 'Agenti' },
{ value: 'O', text: 'Collaboratori' },
{ value: 'L', text: 'Altro' },
]}
caretIcon={<CaretIcon />}
prefix=" "
selectedValue={formik.values.tipoEntry}
onChange={newValue => {
console.log("onChange", newValue);
console.log(formik.values.tipoEntry);
formik.handleChange({
target: {
value: newValue.value,
name: newValue.name
}
});
}}
/>
`
Typescript complains about newValue.value and newValue.name:
Property 'value' does not exist on type '{ altered?: boolean | undefined; text?: string | undefined; name?: string | undefined; value?: string | undefined; } | { altered?: boolean | undefined; options: { text?: string | undefined; name?: string | undefined; value?: string | undefined; }[]; }'. Property 'value' does not exist on type '{ altered?: boolean | undefined; options: { text?: string | undefined; name?: string | undefined; value?: string | undefined; }[]; }'. TS2339
It seems to me something wrong with the type of newValue. Any suggestion?
Thanks for the example. Let me have a look
Hi @repka3 .
Did you try the Formik example on the demo site?