1
如何检查ticketId
已经插入到数组中?React-native数组检查值是否存在
这是代码:
state = { myState: [], status: 0, limit: 5 };
selected(ticketId) {
if (this.state.status < this.state.limit) {
this.state.myState.push({ id: ticketId }); //what ever i chose get inserted
this.state.status++;
this.setState({ status: this.state.status });
//console.log('here', this.state.status);
} else {
console.log('3'); //check if condition meet
}
}
如何创建一个条件检查myState
阵列如果ticketId
已经插入并触发警报?
谢谢你,我得到了正确的结果... –