react-select icon indicating copy to clipboard operation
react-select copied to clipboard

Is there a way to set the inputValue via props when using asyncOptions

Open sambomartin opened this issue 11 years ago • 4 comments

My scenario is that I fetch options from web service, label and value. I then select the options, handle the change and keep value in store. The value of the select is being set via the value property, which when it changes to the value (id) to replaces the value of the input, then triggers another async call to find values using the value in the input (which is now the id).

Is there a way of setting the value and inputValue so the inputValue doesn't get changed to the ID and trigger call to ayncOptions? I don't want to do a fetch against the remote item, when I already have the value and label in the store.

Thanks

sambomartin avatar Aug 20 '15 14:08 sambomartin

When the react-select component is fed a value prop on initial render (consider a parent component's getInitialState feeding in an empty string), and then a call to some backend service is launched and changes the value in the parent state to be an option object - the asyncOptions function is fired off despite the fact that options have not been requested. Traced the issue to componentWillReceiveProps(). When the props change on react-select, it should probably only fire asyncOptions if the autoload prop is true.

Opened a PR to address https://github.com/JedWatson/react-select/pull/477

TigerC10 avatar Sep 23 '15 22:09 TigerC10

Have the similar problem. I have a grid with lots of react-select components. And they all simultaneously call asyncOptions on grid rerender despite of autoload: false

oluckyman avatar Sep 30 '15 10:09 oluckyman

Thanks @TigerC10 - reviewing #477 now, will merge as soon as a potential issue with it is resolved.

JedWatson avatar Sep 30 '15 16:09 JedWatson

Version 1 of react-select is no longer supported.

In the best interest of the community we've decided to spend the time we have available on the latest version.

We apologise for any inconvenience.

Please see:

  1. v1 to v2 upgrade guide
  2. v1 documentation and examples

jossmac avatar Mar 17 '20 06:03 jossmac