Creating new options with AsyncCreatable and Modal
See original GitHub issueI am attempting to use the AsyncCreatable component and would like to open up a modal when a user attempts to create a new option (to gather more information for the option).
I tried passing in onNewOptionClick
to the component, but I am not seeing a way to add the new option after the user has finished with the modal.
I’m thinking perhaps onNewOptionClick
can be passed in a callback function that adds the option once the function is ready.
Something like:
if (isOptionUnique) {
const callback = (option) => {
options.unshift(option);
this.select.selectValue(option);
};
if (onNewOptionClick) {
onNewOptionClick(option, callback);
} else {
callback(option);
}
}
Is there already a better/existing way to accomplish this?
Thanks
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Creatable - React Select
React Select. A flexible and beautiful Select Input control for ReactJS with multiselect, autocomplete, async and creatable support. Star.
Read more >Create an asynchronous Bootstrap 4 modal with React
In a recent project, we wanted a simple way to open a modal in our app asynchronously with custom content. So the solution...
Read more >How to load React-select Async with initial options for edit item ...
React-select will get the data by using a search API that I have and will insert the query behind by using this method:...
Read more >Task asynchronous programming model - Microsoft Learn
Learn when and how to use Task-based async programming, a simplified approach to asynchronous programming in C#.
Read more >Getting Started | Creating Asynchronous Methods - Spring
To model the user representation, create a resource representation class. To do so, provide a plain old Java object with fields, constructors, and...
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
There’s a workaround described here that worked for me: http://www.shahqaan.com/blog/react-select/ Basically, skip
onNewOptionClick
– useonChange
and detect whether it’s a “regular” option or the new option placeholder by testing what properties it has. For instance the placeholder option is given a className property. In my case, my options have adata
property so I test if it’s not there instead.Hello -
In an effort to sustain the
react-select
project going forward, we’re closing old issues.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 aren’t using the latest version of
react-select
please consider upgrading to see if it resolves any issues you’re having.However, if you feel this issue 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!