React Native Radio按钮,带有多个道具

时间:2017-05-28 05:33:02

标签: react-native properties radio-button radio-group

我正在尝试将第3个变量/ prop传递给我的onselect,以便我可以显示已经选择的元素的名称以及值和索引。问题是我一直在为desc定义未定义

_onSelect (index, value, desc) {
    console.log(`Item: ${desc}, index: ${index} , value: ${value}`)
    this.cartFirebase.update(
      {
        index: index,
        price: value
      }
    )
  }

  render () {
    return (
      <RadioGroup
        onSelect={(index, value, desc) => this._onSelect(index, value, desc)}
        color='#009688'
        highlightColor='#fff'
      >
        {(this.props.item || []).map((section, i) => (
          <RadioButton value={section.price} desc={section.description} key={i} style={styles.row}>
            <Text style={styles.title}>{section.description}</Text>
            <Text style={styles.price}>{Settings.priceToPriceWithCurrency(section.price)}</Text>
          </RadioButton>
        ))}
      </RadioGroup>
    )
  }
}

0 个答案:

没有答案