我正在使用 reactFire、Firebase 和 reactJS 构建一个简单的待办事项应用程序。我遇到的问题是当我尝试批量删除列表中已完成的条目时。
componentWillMount: function() {
this.ref = Firebase.database().ref("items/");
this.bindAsArray(this.ref, "items");
this.ref.on('value', this.handleDataLoaded);
}
for (var i in this.state.items) {
var key = items[i]['.key'];
if(items[i].done){
this.ref.child(key).remove();
}
}
循环提前结束,即在删除所有完成的条目之前,因为调用了渲染函数。