Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

How to bind value coming from api react native Picker

$
0
0

How to bind the value coming from API. I am getting value maharastra from api in react native picker.i.e. state_name: maharashtra, This code is for Add form and Update form

  getState(id) {    this.setState({ inputCountry: id })    getState(id)      .then((responseJson) => {        this.setState({ stateData: responseJson })      })      .catch((error) => {        setLoaderVisible(false);      });  }renderStateList() {    return this.state.stateData.map((stateData) => {      return <Picker.Item label={stateData.state}       value={stateData.state} />    })  }<View style={styles.formRow}><View style={{ flexDirection: 'row' }}><Text style={styles.formText}>{__('Current State')}</Text><Text style={{ fontSize: 15, color: 'red' }}>{__('*')}</Text></View><View style={{ borderBottomWidth: 1.5, borderBottomColor: '#92a1c0' }}><Picker                selectedValue={this.state.inputState}                value={this.state.inputState}               //here i need value maharastra                onValueChange={(itemValue, itemIndex) =>                  this.getCity(itemValue)                }>                {this.renderStateList()}</Picker></View></View>

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>