Select.Async with Promise - Shows "[object, object]" in input field when doing a search
See original GitHub issueThis is my Select.Async code:
<Select.Async name="code-chooser" valueKey="codeid" labelKey="codeDescription" value={this.state.chosenCode} loadOptions={this.getCodes} onChange={(code) => {this.setChosenCode(code)}} onInputChange={(value) => { return ""; }} placeholder="Select code..." ignoreCase={ true } clearable={ true } searchable={ true } />
My option object looks like this:
{codeid: "<ID>", codeDescription: "<description>", codeLongDescription: "<long description>"}
As you can see in the onInputChange attribute I just return “”. When I have it like this everything works, but if I instead return the value or if I remove the whole “onInputChange” the input field dosn’t work anymore. As soon as I try to search, the input field just displays “[object, object]”. I also notice that every time I press a key the getCodes-function runs.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:13
- Comments:16 (1 by maintainers)
Top GitHub Comments
I ended up with the following configuration:
The two most important settings are
onInputChange
andfilterOption
. Returning only “” in the onInputChange method prevent the getCodeTypes to run every time you press a key. Then in the filterOption (runs on each element in en dropdown) you return true or false if the element should display or not. This is how my filter-method looks like:This worked for me @jsartisan @diegoconcha .
Hello -
In an effort to sustain the
react-select
project going forward, we’re closing old issues / pull requests.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 version.
If you feel this issue / pull request is still relevant and you’d like us to review it, please leave a comment and we’ll do our best to get back to you.