AdelRedaa97 / react-native-select-dropdown

react-native-select-dropdown is a highly customized dropdown | select | picker | menu for react native that works for andriod and iOS platforms.
MIT License
320 stars 137 forks source link

How can I set a value externally in the Select Dropdown? #71

Closed 360macky closed 1 year ago

360macky commented 2 years ago

Case

I have a select list of items A, B and C. And through a button I want the selected item to be item C.

How can I change the value selected outside the SelectDropdown element?

Thanks in advance!

AdelRedaa97 commented 2 years ago

if you are asking to set a default value you can use defaultValue, If you are asking for a method that you can call it by using the ref, It's not implemented yet I think it's an important feature to be added I'll work on it.

360macky commented 2 years ago

if you are asking to set a default value you can use defaultValue, If you are asking for a method that you can call it by using the ref, It's not implemented yet I think it's an important feature to be added I'll work on it.

Hi Adel! Yes, I'm asking for a method that I can call it using a ref. Not the defaultValue. I achieved that feature with #72.

AdelRedaa97 commented 1 year ago

selectIndex(index) this function is added in v3.0.0 to select an option from outside the component using a ref

360macky commented 1 year ago

Great! Thanks @AdelRedaa97 🎉

Also, I suggest you to add your comment in the Methods table in README.md (like with reset()).