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

additional steps in onChange #249

Open
avianheit07 opened this issue Sep 27, 2022 · 0 comments
Open

additional steps in onChange #249

avianheit07 opened this issue Sep 27, 2022 · 0 comments

Comments

@avianheit07
Copy link

avianheit07 commented Sep 27, 2022

const [selected, setSelected] = useState('');
<SelectSearch
    options={[]}
    value={selected}
    onChange={setSelected}
    getOptions={(query) => {
        return new Promise((resolve, reject) => {
            HTTP_API().get(url)
                .then((response) => {
                    if (response.status === 200) {
                      resolve(response.data.map(({ id, name }) => ({
                            value: id,
                            name: name
                      })));
                    }
                  })
                  .catch(reject);
            });
          }}
    search
    placeholder="To: "
/>

how to add additional steps on onChange and retain its original behaviour? I tried the above code but every time I select an item it closes the dropdown and does not show the selected option.
this is my current version 4.1.2

If I omit the value and onChange properties, the value displays for the selected option but I cannot get and use the value of the selected option.

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

1 participant