javascript - 如何在本机反应中禁用数组响应值上的按钮
问题描述
在我的代码中。IdentificationType 是一个包含所有值的数组。现在我必须禁用以下按钮 CustomButton :条件如果强制:true 和 uploadStatus:false。
我尝试了一些东西,但没有得到结果。
disabled={(!this.state.IdentificationType.uploadStatus == false)&&(this.state.IdentificationType.mandatory===true) }
const {IdentificationType}= this.state;
IdentificationType (3) [{…}, {…}, {…}]
0:
idType: "POID"
name: "Proof Identity"
description: "Upload your identity proof"
mandatory: true
eligibleDocumentList: (3) [{…}, {…}, {…}]
__typename: "IdentificationTypes"
doctype: (3) [{…}, {…}, {…}]
selectValue: "passport"
issueDate: "25/02/2020"
expDate: "25/02/2020"
idNumber: ""
place: ""
image: ""
uploadStatus: false
displayThumbnail: false
fileName: ""
__proto__: Object
1: {idType: "addressProof", name: "Address Proof", description: "Upload your address proof", mandatory: false, eligibleDocumentList: Array(3), …}
2: {idType: "ageProof", name: "Age Proof", description: "Upload your age proof", mandatory: false, eligibleDocumentList: Array(3), …}
length: 3
<View style={{ alignSelf: 'center', paddingTop: 20, position: 'absolute', bottom: 10, zIndex: 10 }}>
<CustomButton backgroundColor={parentStyle[appliedTheme] ? parentStyle[appliedTheme][appliedMode].primaryButtonColor : null}
width={deviceWidth - 30} label={'Save & Proceed'} height={60} labelFontSize={hp('2.5%')}
disabled={true}
onPress={() => this.nextStep()} >
</CustomButton>
</View>
解决方案
{/* before return */}
let {IdentificationType} = this.state;
{/* in render method */}
{IdentificationType && IdentificationType.map(function(value){
<CustomButton disabled={value.mandatory === true && value.uploadStatus === false ? true : false}></CustomButton>
})}
推荐阅读
- node.js - 来自变量 LdapJS 中的 LDAP 查询的数据
- python - Python:直接从 Pandas 加载 Oracle 表(写入 Oracle)
- sql-server - SQL - 将几个日期记录转换为单个日期范围
- java - 如果我只想检查进程是否正常启动,是否应该读取输出/错误流
- azure - 无法安装 VSTS 代理 Azure VM 扩展
- python - 子进程内的python子进程
- unity3d - Unity 未在事件字段中显示公共方法
- java - Junit 配置错误:您必须为此 @ParameterizedTest 提供至少一个参数
- django - gunicorn:在描述的情况下,有没有更好的方法来重新加载 gunicorn?
- xmlunit-2 - XMLUnit - 重复元素名称的不同元素选择器