Skip to content

[1.0.0-beta13] Async options with Promises displays [object Promise] as input value #940

@matejlauko

Description

@matejlauko

When loading options async with Promises, like in the example [object Promise] string is set as input value of Select

const getOptions = (input) => {
  return fetch(`/users/${input}.json`)
    .then((response) => {
      return response.json();
    }).then((json) => {
      return { options: json };
    });
}

<Select.Async
    loadOptions={getOptions}
/>

It is because of #907.

loadOptions from Async component attaches to onInputChange on Select component.
so this

if (this.state.inputValue !== event.target.value && this.props.onInputChange) {
    let nextState = this.props.onInputChange(newInputValue);
    if (nextState != null) {
        newInputValue = '' + nextState;
    }
 }

sets newInputValue to return value of loadOptions, which is [object Promise]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions