0
在我的React-native應用程序中我試圖在我的listenForItems
函數中調用另一個函數,但不斷收到錯誤this.populateArray is not a function. In 'this.populateArray(solutions)', this.populateArray is undefined.
我在其他類中執行此操作,並且它正在工作,但出於某種原因,它在此處不起作用。有什麼我失蹤?在另一個函數內反應本地故障調用函數?
populateArray: function(solutions) {
var completed = [];
var inProgress;
for (var i = 0; i < solutions.length; i++) {
if (solutions[i].completed == 0) {
inProgress = solutions[i].id;
}
else {
completed.push(solutions[i].id);
}
}
},
listenForItems: function(cluesRef) {
var solutions = [];
userSolutionsRef.orderByChild('user_id').startAt(0).endAt(0).once('value', function(snap){
var solution = snap.val();
for (var i = 0; i < solution.length; i++) {
if (solution[0].hunt_id == 0) {
solutions.push(solution[0]);
}
}
this.populateArray(solutions);
});
},