私は、reactFire、Firebase、およびreactJSを使用して単純なTodoアプリケーションを構築しています。私が実行している問題は、リスト内の完成したエントリを一括削除しようとするときです。Firebase - 子ノードの一括削除
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();
}
}
ループは、レンダリング関数が呼び出されるため、完了したすべてのエントリを早期に削除する前に終了します。
'done'は、アイテムの分岐右内側bollean値はありますか? – adolfosrs
実行しているfirebaseのバージョンは? react-fireはFB APIの最新の変更をサポートしていないので私は尋ねています。 –
@adolfosrsはい、私はfirebase 3.0.5とreactfire 1.0.0を使用しています。 – Tannaa