Skip to content

additional steps in onChange #249

@avianheit07

Description

@avianheit07
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions