vtaits / react-select-async-paginate

Wrapper above react-select that supports pagination on menu scroll
MIT License
308 stars 75 forks source link

Question for the existence of "Additional" type #111

Open wibed opened 2 years ago

wibed commented 2 years ago

question

What is the current behavior?

Destructuring arguments which are wrapped in types allowing the object in question to be undefined results in a unreadable structure

const loadOptions: LoadOptions<string, GroupBase<string>, { page: number }> = async (
    searchQuery,
    loadedOptions,
    { page }
  ) => { ... }

What is the expected behavior?

id like to understand the reasoning behind wrapping a single argument inside an optional object. i have to unpack an additional object to get a single argument and destructuring as above is not possible.

vtaits commented 1 year ago

Hello. I thought about this, but I didn't come up with a beautiful solution. I'll try to fix this.

phazei commented 4 months ago

So, I've tried using additional type for more things, like a filter. I'm enjoying the caching that's done with pagination, so if I change the search, then go back to a previous search, it already has it cached. But the component doesn't listen to anything in additional type. I tried adding it to the loadOptions, additional, and defaultAdditional, and nothing.

For example, someone can do a text search in the box and it provides results. So I create a new filter, it's a drop down that affects the results. Suppose the search is for people, then the dropdown could be male/female/either.

additional: {
     page: page,
     filterGender: filterGender
}

I would expect that if I change the filterGender, then the component would see additional has changed, so will either provide the cached results if they exist, or otherwise call loadOptions with that filter option as part of additional. That would make sense as a use case for additional. Actual result is nothing happens, so the only way I have to change the filter is:

Which reloads the entire thing and loses all caching. Would really love to `additional` working as something that allows additional data for triggering different results, but currently it really seems like it can only be used for the page.
vtaits commented 4 months ago

@phazei

cacheUniqs={[filterGender]}