danish1658 / react-native-dropdown-select-list

☝️ React Native Select List Equivalent to Html's Select with options"
https://www.npmjs.com/package/react-native-dropdown-select-list
MIT License
193 stars 90 forks source link

multi dropdown default option fix #74

Open PnCodeBreaker opened 1 year ago

PnCodeBreaker commented 1 year ago

This package really is a life saver for us as it allows us to use a searchable dropdown inside a scrollview, other packages we could not use it and in our app we need drop downs everywhere. Though as this package uses scrollview instead of flatlist but even for 100-200 data in dropdowns it is performing quite well.

But the main problem right now with this package is we can't get default option working in MultiSelect Dropdown so if we want to pre-fill selected data then we were unable to do it.

So I have come up with a solution and fixed the multioption default option which was not working. Though I have tested But this feature is a much needed for me so I would request you to test and merge this fix.

In DefaultOption though instead of key value pair we have to give normal array of strings.

<MultipleSelectList setSelected={(val) => setSelected(val)} data={data} save="value" onSelect={() => alert(selected)} label="Categories" defaultOption={['Computers', 'Cameras']} />

So this is how we can use default option.

Dev2Slope commented 1 year ago

defaultOption={['Computers', 'Cameras']}

What is 'Computers' and 'Cameras'?? key or value? Please specify a little more.

I tried this and its not working, there isn't a new version to update yet.

PnCodeBreaker commented 1 year ago

defaultOption={['Computers', 'Cameras']}

What is 'Computers' and 'Cameras'?? key or value? Please specify a little more.

I tried this and its not working, there isn't a new version to update yet.

'Computers' and 'Cameras' are values not key. So instead of Object in key, value pairs, default option can be just added with array of values.

I have forked this project & created a different npm release ( as I got no response from the original creator of this package ) also where i have added several enhancements & fixes on top of this package. As I use this package in our company's app also there are several customisations added on my custom fork according to our requirements. Though I have not created a very detailed documentation for that, I will be adding a detailed documentation in future.

I am attaching the link npm : https://www.npmjs.com/package/react-native-dropdown-select-list Github Repo : https://github.com/PnCodeBreaker/react-native-dropdown-select-list

I would still had preferred to collaborate with the original Devs and it would be better for the entire community.