Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/417.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在React Native中选择FlatList项?_Javascript_React Native - Fatal编程技术网

Javascript 如何在React Native中选择FlatList项?

Javascript 如何在React Native中选择FlatList项?,javascript,react-native,Javascript,React Native,我有以下代码: renderRooms = ({item:room}) => { return( <View style={styles.cards}> <View style={styles.cardRight}> <View style={{ marginLeft:2, alignItems: 'center', flex:1 }}> <Text style={{fontSize:12

我有以下代码:

renderRooms = ({item:room}) => {
  return(
    <View style={styles.cards}>
      <View style={styles.cardRight}>
        <View style={{ marginLeft:2, alignItems: 'center', flex:1 }}>
          <Text style={{fontSize:12, marginTop:10, marginBottom: 5, color:'#B0B0B0'}}>
             Harga/malam
          </Text>      
          <Text style={{fontSize:12, textDecorationLine:'line-through'}}>              
            {`${'Rp.'}${room.pricing.normal}`}
          </Text>
          <Text style={{fontSize:14, fontWeight:'800', color:'#26de81', }}>
            {`${'Rp.'}${room.pricing.discount}`}
          </Text>
          <CheckBox
            // center
            iconRight
            title={this.state.showContinueToPayment == true ? 'Batal' : 'Pilih'}                                                            
            checked={this.state.showContinueToPayment}
            containerStyle={{padding:5, borderColor:'white', backgroundColor:'white'}}
            onPress={() => this.setState({showContinueToPayment: !this.state.showContinueToPayment})}
          />
        </View>
      </View>
    </View>
  )
}
renderRooms=({item:room})=>{
返回(
哈尔加/马拉姆
{${Rp.}${room.pricing.normal}}
{`${Rp.}${room.pricing.折扣}`}
this.setState({showContinueToPayment:!this.state.showContinueToPayment})的
/>
)
}

关于这一部分:

<CheckBox
  iconRight
  title={this.state.showContinueToPayment == true ? 'Batal' : 'Pilih'}                                                                                            
  checked={this.state.showContinueToPayment}
  containerStyle={{padding:5, borderColor:'white', backgroundColor:'white'}}
  onPress={() => this.setState({showContinueToPayment: !this.state.showContinueToPayment})}
/>
this.setState({showContinueToPayment:!this.state.showContinueToPayment})}
/>
我希望能够设置我的
复选框的
状态
,但我无法完成

我正在使用一个
平面列表
,当我渲染我的应用程序时,这个
渲染图
给我2个列表。我认为问题是这两个列表应该有自己的状态。但我不知道怎么做


正在寻找一些帮助。感谢您的光临。

我认为在返回之前,您仍然可以在渲染中获得所需的范围。您可以在那里定义您的函数,比如“handleOnCheckboxPress”,并提供您当前在OnPress上拥有的代码。然后在OnPress上,您可以调用该函数。请为整个组件类添加代码