我正在使用react-native-flexi-radio-button(https://github.com/thegamenicorus/react-native-flexi-radio-button),但是我想使用json值循环播放单选按钮,并且它不起作用。看看下面的代码。预先感谢
这有效
<RadioGroup
onSelect={(index, value) => this.onSelect(index, value)}>
<RadioButton value={"item1"}>
<Text>This is item #1</Text>
</RadioButton>
</RadioGroup>
但是以下给出的内容无法读取null的属性“ props”
<RadioGroup
onSelect={(index, value) => this.onSelect(index, value)}
>
{this.state.cuisinesByFoodList.map(item1 => {
console.log("result", item1);
<RadioButton value={"abc"}>
<Text>{"abc"}</Text>
</RadioButton>;
})}
</RadioGroup>
P.S there's value in item1 in the console when debugged.
答案 0 :(得分:0)
您忘记return
了。
<RadioGroup
onSelect={(index, value) => this.onSelect(index, value)}
>
{this.state.cuisinesByFoodList.map(item1 => {
console.log("result", item1);
return(<RadioButton value={"abc"}>
<Text>{"abc"}</Text>
</RadioButton>);
})}
</RadioGroup>