Async single select
Default data fetching
Section titled “Default data fetching”To define how label, value, subtitle (optional), and icon (optional) are defined in the options, use getLabel, getValue, getSubtitle, getIcon.
<AsyncSelect value={value} onChange={(value) => setValue(value)} fetchUrl={(searchText) => searchText?.length >= 3 ? `http://example-api.com?limit=5&search=${searchText}` : 'http://example-api.com?limit=5' } getLabel={(item) => item?.name} getValue={(item) => item?.id}/>Alternate data fetching
Section titled “Alternate data fetching”Provide a function that fetches data asynchronously and returns it in the format of an array of objects with label and value properties.
const getOptions = async () => { ...};
<AsyncSelect value={value} onChange={(value) => setValue(value)} fetchFunction={getOptions}/>For the complete list of props, use your IDE’s autocomplete functionality.