react-native-flexi-radio-button
react-native-flexi-radio-button copied to clipboard
how can I know what I select in every group
I want to know what i select in every group ,but i can't do it. everybody hlpe me, please this is my data
this is this.state.data: Array [
Object {
"A": "采取国务院发布的放假方案调休,共四天假期",
"B": "在上述方案下再将前一周的周六调至五一假期中,共五天假期",
"C": null,
"D": null,
"qid": 1,
"tid": 1,
"title": "五一即将来临,我们将对五一的休假计划做意见收集",
},
Object {
"A": "不补假",
"B": "补周一的假",
"C": "补周二的假",
"D": "补周3的假",
"qid": 1,
"tid": 2,
"title": "五一补假方案",
},
Object {
"A": "参加",
"B": "不参加",
"C": null,
"D": null,
"qid": 1,
"tid": 3,
"title": "五一是否参加学校组织的活动",
},
Object {
"A": "不去玩,认真学习",
"B": "在家自己玩",
"C": "找朋友玩",
"D": "出去玩",
"qid": 1,
"tid": 4,
"title": "五一不参加活动你去哪里玩",
},
]
this is my demo
onSelect=(index, value)=>{
console.log(`you select ${index} and result is ${value}`)
this.setState((prevState)=>{
var arr = prevState.select;
arr[index]=value;
return{
select: arr
}
})
}
this.state.data.map((values,index)=>{
var {A,B,C,D,E,F,G,H,I} = values;
return (
<View
key={values.title}
>
<View style={{marginTop:15}}>
<Text>{`${index+1}.${values.title}`}</Text>
</View>
<RadioGroup
key={index}
onSelect={(index, value) => this.onSelect(index, value)}>
<RadioButton value={`A`}>
<Text>{`A.${A}`}</Text>
</RadioButton>
<RadioButton value={`B`}>
<Text>{`B.${B}`}</Text>
</RadioButton>
<RadioButton value={`C`} style={{display: C ? "flex" : "none"}}>
<Text>{`C. ${C}`}</Text>
</RadioButton>
<RadioButton value={`D`} style={{display: D ? "flex" : "none"}}>
<Text>{`D. ${D}`}</Text>
</RadioButton>
</View>)
})
}