First of all, thank for your all components it's very good. I am using picker component. It's all working fine. My question is how to get a selected Label name. I am getting only selected index value. Please give me any suggestion. Thanks in advance
Here is my code:
import React, { Component } from 'react'
import { Platform } from 'react-native'
import { Container, Header, Title, Content, Button, Icon, Text, Right, Body, Left, Picker, Form, Item } from 'native-base'
var array = [
{
label: 'Wallet'
},
{
label: 'ATM Card'
},
{
label: 'Debit Card'
},
{
label: 'Credit Card'
},
{
label: 'Net Banking'
}
]
export default class Courses extends Component {
constructor(props) {
super(props)
this.state = {
selected2: undefined,
labelName: ''
}
}
onValueChange2(value, label) {
this.setState(
{
selected2: value,
labelName: label
},
() => {
console.log('selectedValue: ' + this.state.labelName)
}
)
}
render() {
var description = []
{
array.map((res, i) => {
description.push(<Item label={res.label} value={i} />)
})
}
return (
<Container>
<Header>
<Left>
<Button transparent onPress={() => this.props.navigation.goBack()}>
<Icon name="arrow-back" />
</Button>
</Left>
<Body>
<Title>Placeholder Picker w/o Note</Title>
</Body>
<Right />
</Header>
<Content>
<Form>
<Picker mode="dropdown" placeholder="Select One" note={false} selectedValue={this.state.selected2} onValueChange={this.onValueChange2.bind(this)}>
{description}
</Picker>
</Form>
</Content>
</Container>
)
}
}
Finally, I got an answer.
{
array.map((res, i) => {
description.push(<Item label={res.label} value={res.label} />)
})
}