【发布时间】:2018-08-23 22:08:02
【问题描述】:
上面是我在尝试将数据插入到 firebase db 时遇到的错误的快照。
constructor(props) {
super(props);
this.app = firebase.initializeApp(DB_CONFIG);
this.database = this.app.database().ref().child('notes');
this.state = {
notes : [],
}
}
componentWillMount() {
const prevNotes = this.state.notes;
this.database.on('child_added', snap => {
prevNotes.push({
id: snap.key,
data: snap.val().data,
})
this.setState({ notes: prevNotes });
})
}
addNote(e) {
if(e.which === 13) {
this.database.push().set({ data: e.target.value });
}
}
上面是我在数据库中添加注释的反应代码,我正在制作一个待办事项列表,addNote() 将在按键 ENTER 时添加一个新注释。
请帮帮我,我是第一次使用 firebase,是否有任何代理问题可能导致此问题?
【问题讨论】:
标签: reactjs firebase firebase-realtime-database firebase-security