react-native-flexi-radio-button
react-native-flexi-radio-button copied to clipboard
Unselection of radio button
I am using this module, it's all working fine. But i have a dynamic data it displays in ListView. Once i have selected one option in ListView then the index value will be changed. After i have to select another option then the index value will be changed but the radio button will be in multiple selected mode. Here is my code:
onSelect(index, value){
this.setState({
index:index,
value:value
},()=>{
this.setState({
text:'Selected index:'+this.state.index+' , value: '+this.state.value
})
})
}
listRow(list, sectionID:number, rowID:number){
var attributes=[];
list.options.map((list,i)=>{
attributes.push(
<View style={styles.listOfAttributesView}>
<View style={styles.dataRowAttributesView}>
<RadioGroup
onSelect = {(index, value) => this.onSelect(index, value)}
color={'black'}
size={20}
thickness ={2}>
<RadioButton value={list} >
<Text>{list}</Text>
</RadioButton>
</RadioGroup>
<Text>{this.state.text}</Text>
</View>
</View>
)
})
return(
<View>
{attributes}
</View>
)
}
Here is my screenshot:
Please give me suggestion. Thank you
I encountered the same problem,How do you solve?
I am also facing same problem.
anybody have any idea to solve this problem.
try this
<RadioGroup onSelect={(index, value) => this._onSelect(index, value)}> {this._renderRadioBtn()} </RadioGroup>
_renderRadioBtn = () => this.props.foo.map(item => ( <RadioButton value={item} > <Text>{item.name}</Text> </RadioButton> ));
don't map RadioGroup (you multiply onSelect fn())
I have also same problem,Any hint ?
just creat function like this
onSelect(index, value) {
this.setState({
selectedIndex: index
})
}
selectedIndex is state variable
Please send the props "selectedIndex" as null when you want to clear it.