在这里,我在文本字段上调用alart函数onPress。 在调用该功能时,我试图打开警报,并在确认时在调用其他功能。 但是如果我打电话给“ showAlert1()”,它就会死机。此功能多次被调用 我必须在showPress上调用showAlert()函数,并且必须在中发送一些值。然后在Alert的确认OK按钮上,我必须上传到服务器。
showAlert1(code,name,version) {
console.log("data alaert abc",code,version);
Alert.alert(
'Confirmation','Are you sure you want to migrate this tariff',[
{
text: 'Cancel',onPress: () => console.log('Cancel pressed'),style: 'Cancel',},{ text: 'Proceed',onPress: () => this.confirmTariffMigration(code,version) },]
);
}
confirmTariffMigration = (code,version) => {
console.log("hhhhdhhdhdhdhhdd",version);
const objData = {
addofferingactionCode: '',offeringCode: '',offeringName: ''
}
this.props.updatetariffMigration(objData)
}
<View style={{ marginLeft: 5,marginRight: 5,marginTop: 10,backgroundColor: '#f1f1f1' }}>
{
tariffMigrationData.map((data,index) => {
return (
// <TouchableOpacity key={index} onPress={this.showAlert1(data)}>
<View style={{ marginBottom: 10,marginLeft: 5,marginRight: 5 }} key={index}>
<Card>
<CardItem header style={{ backgroundColor: '#fff',width: '100%',justifyContent: 'space-between',borderBottomColor: '#f1f1f1',borderBottomWidth: 1 }}>
<View style={{ flexDirection: 'column',justifyContent: 'space-between' }}>
<View>
<RegularText text={`${data.offering.name}`} style={{ fontWeight: 'bold' }} />
<SmallText text={` ID ${data.offering.code}`} textColor="grey" />
</View>
</View>
<View style={{
backgroundColor: 'blue',borderRadius: 75,height: 25,paddingRight: 10,paddingLeft: 10,paddingTop: 5
}}>
<SmallText text={'Proceed'} onPress={this.showAlert1(data.offering.code,data.offering.version,data.offering.name)} textColor='white' />
</View>
</CardItem>
</Card>
</View>
)
}
}
</View>