Reputation: 3027
I'm using react-native-flexi-radio-button (https://github.com/thegamenicorus/react-native-flexi-radio-button) but I want to loop the radio buttons using the json values and its not working. Have a look at the code below. Thanks in advance
This works
<RadioGroup
onSelect={(index, value) => this.onSelect(index, value)}>
<RadioButton value={"item1"}>
<Text>This is item #1</Text>
</RadioButton>
</RadioGroup>
But the following gives cannot read property 'props' of null
<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.
Upvotes: 0
Views: 2404
Reputation: 5135
You forgot to return
the items.
<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>
Upvotes: 2