AsyncCreatable not working- Newly created value not getting set
See original GitHub issueHi @bvaughn ,
I’m using the AsyncCreatable component and facing an issue where the newly created value is not getting applied. Here’s the code:
import React, { Component } from "react";
import { autobind } from "core-decorators";
import axios from "axios";
import { AsyncCreatable } from "react-select";
@autobind
class SampleComponent extends Component {
constructor(){
super();
this.state={ usaStates: {} }
}
onChange(itemId, selectedItem) {
this.setState({
[itemId]: selectedItem || {}
});
}
loadStateData(input, callback) {
axios("/data/states.json").then((response) => {
callback(null, { options: response.data, complete: true });
});
}
render() {
return <AsyncCreatable id="usaStates" value={this.state["usaStates"].value} loadOptions={this.loadStateData} onChange={this.onChange.bind(this, "usaStates")}></AsyncCreatable>;
}
}
export default SampleComponent;
Is there a fix/workaround for this? Any input appreciated. Thanks!
Issue Analytics
- State:
- Created 6 years ago
- Reactions:16
- Comments:9
Top Results From Across the Web
Why "Create" option isn't visible in AsyncCreatableSelect in ...
I found this solution: import React from "react"; import AsyncCreatableSelect from "react-select/async-creatable"; const TestComponent ...
Read more >react-select-old - npm
Start using react-select-old in your project by running `npm i ... Select ) to allow new options to be created if they do...
Read more >Advanced - React Select
A flexible and beautiful Select Input control for ReactJS with multiselect, autocomplete and ajax support.
Read more >How to use the react-select.Async function in react-select | Snyk
To help you get started, we've selected a few react-select. ... Use Snyk Code to scan source code in minutes - no build...
Read more >React-Select Makes Creating Selectable Menus Easy
Line 20: Shows the loading animation with isLoading being set. Line 22: Shows the preselected value, “Apple” . Since isClearable is set, it...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here is an example of the issue: https://codesandbox.io/s/43ym8zxzk7
You can download code to local disk.
As @elie222 stated, the
onCreateOption
does not callonChange
as per the documentation.I will be closing this issue now, but if there are any other questions or concerns, feel free to create a new ticket or discussion to address these.