0

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.

1 Answer 1

2

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.