-
Have implemented react-select in one of our projects, and really happy with it. Is there any way to enable CreateableSelect and also grouped options? From what I can tell, there is not. Which is understandable, because it would either need a default option group, or additional components for the user to specify in which group they want the option to be included. And understandably a bit of an edge case, I imagine. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
So just to follow up in case anyone else run into this... it seems this actually is possible. The problem I was running into is that there are two different importable objects named CreateableSelect. My IDE had imported the wrong one and I didn't realize it. The incorrect one is: While this loaded a functioning grouped/multiselect, it did not allow creating new items. This is the correct import, as displayed in the documentation:
I'm going to use a modal hooked into onCreateOption to display my groups using CreateableSelect to allow selection/creation of new groupings. |
Beta Was this translation helpful? Give feedback.
So just to follow up in case anyone else run into this... it seems this actually is possible. The problem I was running into is that there are two different importable objects named CreateableSelect. My IDE had imported the wrong one and I didn't realize it.
The incorrect one is:
import CreateableSelect from 'react-select'
While this loaded a functioning grouped/multiselect, it did not allow creating new items.
This is the correct import, as displayed in the documentation:
import CreateableSelect from 'react-select/creatable'
I'm going to use a modal hooked into onCreateOption to display my groups using CreateableSelect to allow selection/creation of new groupings.