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
已經插入並觸發警報?
謝謝你,我得到了正確的結果... –