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上,您可以调用该函数。请为整个组件类添加代码