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

How to solve react native null value in picker?

$
0
0

I've been working on a react native application on the Android Platform. I implemented a DropDown picker but it gives an error.

The code piece that gives the error:

<View style={styles.if_filterbox}>
    <View style={{ alignSelf: 'center', paddingTop: 5 }}>
        <Text style={styles.if_formLabel}>Adres Seçiniz</Text>
    </View>


    <View style={{ flex: 1, flexDirection: 'column' }}>
        <View style={{ flex: 0.5, flexDirection: 'row' }}>


        <View style={styles.if_regionselect}>
            <Picker
            selectedValue={this.state.cityID}
            style={styles.if_picker}
            mode="dropdown"
            onValueChange={(itemValue, itemIndex) => {
                if (itemValue !== 0) {
                this.setState({
                    city: this.state.cities[itemValue],
                })
                }
            }
            }>
            {this.checkIsCitySelected()}
            {Object.keys(this.state.cities).map(key => {
                return <Picker.Item label={this.state.cities[key].isim} value={key} />
            })}
            </Picker>
        </View>
        </View>
    </View>
</View>  

checkIsCitySelected = () => {
    if (this.state.cityID >= 0) {
      return (<Picker.Item label={this.state.city["isim"]} value={this.state.cityID} />)
    } else {
      return (<Picker.Item label='Şehir Seçiniz' value='-1' />)
    }
  }

I know that cities array is not empty.

Error: Android Dropdown Error


Viewing all articles
Browse latest Browse all 30349

Trending Articles



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