Open KoalaBear opened 11 months ago
I had raised a pull request to Koala's repo so as to make the defaultOptions work with save props ('key' or 'value') and also in a format similar to defaultOption in Select. Not sure whether want to keep it as defaultOption too in the MultiSelect instead of defaultOptions
const App = () => {
const [selected, setSelected] = React.useState([]);
const data = [
{key:'1',value:'Jammu & Kashmir'},
{key:'2',value:'Gujrat'},
{key:'3',value:'Maharashtra'},
{key:'4',value:'Goa'},
]
return(
<MultipleSelectList
onSelect={() => alert(selected)}
setSelected={(val) => setSelected(val)}
data={data}
save="key"
defaultOptions={[ {key:'1', value:'Jammu & Kashmir' }, {key:'4', value:'Goa' }]} //default selected options
/>
)
};
As KoalaBear mentioned, I saw that MultipleSelectList has a defaultOptions property, but it is not implemented. I am working on an app right now where this functionality would be very helpful. Please get this reviewed and merge soon. Thanks.
Hello, I have been using the library and it would be great to have the functionality of sending the default values to the MultiSelectList. Could you please continue with this PR? Thank you @danish1658
The current
defaultOption
exists on bothMultipleSelectList
andSelectList
while it is only implemented forSelectList
. So I added adefaultOptions
variable & implemented it forMultipleSelectList
in order to be able to load up a list of previously selected values from my app storage.