hoaphantn7604 / react-native-element-dropdown

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

How to pass already selected data? #113

Open premdasvm opened 2 years ago

premdasvm commented 2 years 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 2 years 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 2 years 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 2 years ago

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