react-native-flexi-radio-button icon indicating copy to clipboard operation
react-native-flexi-radio-button copied to clipboard

Unselection of radio button

Open harikanammi opened this issue 7 years ago • 7 comments

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: screen shot 2017-09-28 at 12 12 01 pm Please give me suggestion. Thank you

harikanammi avatar Sep 28 '17 06:09 harikanammi

I encountered the same problem,How do you solve?

ZaL0-0 avatar Jan 16 '18 03:01 ZaL0-0

I am also facing same problem.

ghost avatar Mar 16 '18 06:03 ghost

anybody have any idea to solve this problem.

vijaya06 avatar May 15 '18 06:05 vijaya06

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())

MrPistoul avatar May 24 '18 08:05 MrPistoul

I have also same problem,Any hint ?

abduliOS avatar Aug 13 '18 07:08 abduliOS

just creat function like this

onSelect(index, value) {
    this.setState({
       selectedIndex: index
   })
}

selectedIndex is state variable

muhtar93 avatar Oct 11 '18 08:10 muhtar93

Please send the props "selectedIndex" as null when you want to clear it.

PradeepNedun avatar Mar 15 '19 06:03 PradeepNedun