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

Question for the existence of "Additional" type #111

Open
wibed opened this issue Apr 6, 2022 · 3 comments
Open

Question for the existence of "Additional" type #111

wibed opened this issue Apr 6, 2022 · 3 comments
Labels

Comments

@wibed
Copy link

wibed commented Apr 6, 2022

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
Copy link
Owner

vtaits commented Dec 5, 2022

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

@vtaits vtaits added the typings label Dec 5, 2022
@phazei
Copy link

phazei commented Jul 4, 2024

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
Copy link
Owner

vtaits commented Jul 8, 2024

@phazei

cacheUniqs={[filterGender]}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants