thegamenicorus / react-native-flexi-radio-button

Simple and flexible Radio button for React Native App
https://www.npmjs.com/package/react-native-flexi-radio-button
MIT License
159 stars 64 forks source link

Can I pass a couple of values or props apart from index and value in RadioGroup #31

Closed bbeckk closed 6 years ago

bbeckk commented 6 years ago

I wonder if other values like index and value props can be passed . For instance Here we can get the selected index and selected value. But I wonder whether I can pass other props (like id from json below) to the radioGroup as well too. I want to pass the id as well. How can I do that?

onSelect(index, value) {
    console.log('selected index and value', index + value);
}

<View style={styles.border}>
    <RadioGroup
      onSelect={(index, value) => this.onSelect(index, value)}
    >
      {this.state.foodList.map(item1 => {
        return (
          <RadioButton value={item1.food}>
            <Text>{item1.food}</Text>
          </RadioButton>
        );
      })}
    </RadioGroup>
</View>

Json data

{"foodList": [
    {
      "id": 40,
      "food": "Bagels",
    },
    {
      "id": 27,
      "food": "Beverage",
    },
    {
      "id": 5,
      "food": "Burger",
    }
]}