react-native-select-dropdown icon indicating copy to clipboard operation
react-native-select-dropdown copied to clipboard

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

Open marcelo-earth opened this issue 3 years ago • 2 comments

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!

marcelo-earth avatar Jun 15 '22 03:06 marcelo-earth

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.

AdelRedaa97 avatar Jun 16 '22 11:06 AdelRedaa97

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.

marcelo-earth avatar Jun 16 '22 15:06 marcelo-earth

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

AdelRedaa97 avatar Oct 21 '22 15:10 AdelRedaa97

Great! Thanks @AdelRedaa97 🎉

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

marcelo-earth avatar Oct 21 '22 16:10 marcelo-earth