chymtt / ReactNativeDropdownAndroid

A simple wrapper for Android's Spinner in react-native
MIT License
61 stars 22 forks source link

How to programmatically set the selected value? #8

Closed euwyn closed 8 years ago

euwyn commented 8 years ago

The 'selected' prop works well to set the initially selected value, but given that we can't change props, is there a way to programmatically change the value?

chymtt commented 8 years ago

You can always use state. For example:

<Dropdown
    style={...}
    values={...}
    selected={this.state.selected} />

And somewhere else:

this.setState({ selected: 2 });

Hope that helps!