0
如何使用React设置Firebase数据库顶级的值。使用React设置Firebase数据库顶级的值
一个教程(付费墙后面)解释了如何在子记录中设置一个值,但我还没有弄清楚如何在顶层执行该操作。
更新子记录:
componentDidMount: function() {
this.ref = new Firebase('<url>');
var childRef = this.ref.child(this.props.params.username);
this.bindAsArray(childRef, 'notes');
},
handleAddNote: function(newNote) {
this.ref.child(this.props.params.username)
.child(this.state.notes.length).set(newNote);
}...
试图做一些像下面,但不知道如何得到物品的长度在顶层。
componentDidMount: function() {
this.ref = new Firebase('<url>');
this.bindAsArray(this.ref, 'notes');
},
handleAddNote: function(newNote) {
this.ref.child(this.state.notes.length).set(newNote);
}...
我几天前开始反应,所以任何建议将不胜感激。