Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using react-responsive-select with formik+typescript #161

Open
repka3 opened this issue May 11, 2021 · 2 comments
Open

using react-responsive-select with formik+typescript #161

repka3 opened this issue May 11, 2021 · 2 comments

Comments

@repka3
Copy link

repka3 commented May 11, 2021

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?

@benbowes
Copy link
Owner

Thanks for the example. Let me have a look

@benbowes
Copy link
Owner

Hi @repka3 .

Did you try the Formik example on the demo site?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants