zubairpaizer / react-native-searchable-dropdown

Searchable Dropdown
148 stars 98 forks source link

Cannot change/set value dynamically #33

Open vivek25constants opened 4 years ago

vivek25constants commented 4 years ago

defaultValue works only for the first time, changing it does not updated the value.

alhaiz313 commented 4 years ago

I am facing the same problem. Did you find a solution please?

zeroonedev01 commented 4 years ago

same problem

appielife commented 4 years ago

+1

alhaiz313 commented 4 years ago

make the defaultValue part of the state. That way every time it changes the page will re-render

nirmaldalmia commented 4 years ago

Facing the same problem. I initialize selected index in state to 0 and after an API call, I update the state with the new index but the selected item doesn't change.

leandrorocha commented 4 years ago

any example? , I didn't understand how to set the value.

nirmaldalmia commented 4 years ago

@leandrorocha suppose I make the dropdown with options as numbers from 1 to 10. I initialized it using the default value 1. Then, I make an API call to fetch the actual value from backend and updated the default value variable to that value say 5. The problem is, the dropdown selected value doesn't change to 5 and remains at 1.