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

added shouldReloadOptions option to Async component #1480

Closed
wants to merge 2 commits into from

Conversation

VanCoding
Copy link
Contributor

Hi @JedWatson

I had the need to add an option to the Async component that lets it automatically reload its options when it receives new props or the user opens the list.

As use case, imagine the following UI:

Client: [Client Select Box]
Invoice: [Invoice Select Box]

The invoice select box lets you select an invoice of the client selected in the client select box.
As soon as you select a different client, and then want to select the invoice, you should get the invoices of the new client.

Currently, the Async component assumes that a call to loadOptions with the same search term will always return the same options, and therefore does not reload its options when receiving new props, or opening the list. But in the use case above, that is not the case. loadOptions would return different options, if it was called. But it isn't!

That's why I added the option shouldReloadOptions, which is a function that, when called, returns a boolean value indicating if a call to loadOptions would return different results than before. If it returns true, the Async component then automatically reloads its options.

What do you think?

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.5%) to 91.858% when pulling e5265dc on VanCoding:master into ef3a468 on JedWatson:master.

@bobsmits
Copy link

Can this be merged, got the same problem?

@brendanluna
Copy link

+1

@VanCoding
Copy link
Contributor Author

@dave-clover No. This is thought as an addition to disabling the cache.

@ajbdev
Copy link

ajbdev commented Feb 28, 2017

Is there anything preventing this from being merged in? I'm using a pretty ugly workaround to mimic this behavior by conditionally rendering two different components that are nearly identical aside from their loadOptions function. It would be nice to have this as a built in option instead.

@obykoo
Copy link

obykoo commented Mar 1, 2017

Is this at npm ? or not released yet?

@alanhr
Copy link

alanhr commented Mar 9, 2017

I have the same problem on my app. :(
When this Pr will be merged in master?

@alanhr
Copy link

alanhr commented Mar 18, 2017

Could you fix your PR @VanCoding ?
I need a lot of this feature.

@VanCoding
Copy link
Contributor Author

fixed.

@alanhr
Copy link

alanhr commented Mar 29, 2017

@VanCoding thanks ;)

@tommyalvarez
Copy link

Any news on this? I also need to refresh the options due to cascading selects dependency.

@eliseumds
Copy link

That would be great to have!

@rcarausu
Copy link

rcarausu commented Sep 5, 2017

I'm also waiting on this cool little feature :)

@asaarnak
Copy link

asaarnak commented Dec 9, 2017

Any news on this ?

@mmmikeal
Copy link

mmmikeal commented May 7, 2018

can we get an example of how shouldReloadOptions is to be used? I must be stupid....

shouldReloadOptions={true}
and then call on the options whenever we need it updated? how?

EDIT: looks like I should pass a function shouldReloadOptions={this.reload}

and whenever I want it to reload i execute this.reload() ?

@gwyneplaine gwyneplaine self-assigned this Jul 4, 2018
@jossmac jossmac added the v1 label Jul 4, 2018
@flexdinesh
Copy link
Collaborator

Hey @VanCoding v1 of react-select is no longer maintained.

Thanks for taking your time out to create this PR but since this PR has changes for v1, we cannot merge it right away. If you would like to discuss this feature for the latest versions of react-select, please open an issue with feature details and we could move forward with the discussion there. We understand this might be inconvenient but in the best interest of supporting the broader community we have to direct our limited efforts to maintain the latest versions.

We highly recommend upgrading from v1 to v2.

I'm closing this issue/PR now. Feel free add your thoughts in #3981 and reference this issue/PR if needed.

@flexdinesh flexdinesh closed this Mar 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.