jakezatecky / react-dual-listbox

A feature-rich dual listbox for React.
https://jakezatecky.github.io/react-dual-listbox/
MIT License
110 stars 59 forks source link

Is it possible to load async options? #63

Closed oscarlnetoo closed 1 year ago

oscarlnetoo commented 5 years ago

Hello @jakezatecky,

I am needing to load async options from a remote source as the user types. Is it possible to do with this component?

jakezatecky commented 5 years ago

When you say "as the user types" are you referring to the filter input? Currently, there is no built-in mechanism for asynchronous load, as the component uses the same set of options for both list boxes and filterCallback is iterated through the already available options.

I definitely see value in having support for asynchronous loading of options based on user input. I am thinking it might make sense to have a property like asyncOptions where it is called in whenever the available filter changes and that it should return a list of options.

This would supersede the existing options property and likely would require that the selected property be an array of { label, value } options instead of just strings. I might follow the route of react-select and just create a separate component to import, AsyncDualListBox to enforce that requirement.

oscarlnetoo commented 5 years ago

Thank you for the reply!

Yes, I am referring to the filter input. I know the async component of react-select. It's the same idea, but I want a dual list instead of a select. I would appreciate that feature in your lib.

jakezatecky commented 1 year ago

An example of asynchronous loading of options using the onFilterChange callback is now present in the v6.0-dev branch.