hoaphantn7604 / react-native-element-dropdown

A react-native dropdown component easy to customize for both iOS and Android.
MIT License
951 stars 165 forks source link

How to pass already selected data? #113

Open premdasvm opened 1 year ago

premdasvm commented 1 year ago

Hi,

I've a dropdown component where i use react-native-element-dropdown for selecting branches when I try to create a new product. What I'm trying to achieve is to use the same screen for the product's edit. I already have a array of branches previously selected which I need to show as already selected along with my whole like.

I tried updating the array assigned as the value in the MultiSelect component. Is there a way to show selected data ?

anujd61 commented 1 year ago

Can you share your code? I had the same error just now, the problem I was I was assigning the value array with [{label:1,value:"Foo"}] . Changed the value array to just an array of values like ["Foo"] and it worked.

premdasvm commented 1 year ago

@BigDaddy-Zephyr I was doing the same thing with my value, I changed that to something like ["Foo"] now it's working like you said. Thanks for the help mate.

But theoretically it should work the other way around also right? 🤔 @hoaphantn7604

hoaphantn7604 commented 1 year ago

hi @premdasvm , Currently MultiSelect assigning value ["foo"]. I will upgrade this package to support both formats.