【发布时间】:2016-08-16 21:06:28
【问题描述】:
尝试从 Firebase 3.x.x 获取数据表以与我的 React 应用同步。据我所知,这是用于同步两种状态的最流行的库。括号内填入适当的数据。
App.js:
componentDidMount() {
var base = Rebase.createClass({
apiKey: "[API Key]",
authDomain: "[app-name].firebaseapp.com",
databaseURL: "https://[my-app].firebaseio.com",
storageBucket: "[app-name].appspot.com",
})
base.syncState(`records`, {
context: this,
state: 'records',
asArray: true
})
}
当我打电话时
console.log(this.props.state.records)
我得到一个空数组(在 state.js 中初始化的那个) 我在 firebase 中的数据如下所示:
https://[app-name].firebaseio.com/:
[app-name]{
records[
record_1{
id: 0
description: "this is a record"
}
record_2{
id: 1
description: "this is another record"
}
]
}
编辑:我认为这与身份验证无关。在 database.rules.sjon 中将 read 和 write 设置为 true 没有产生任何结果。
编辑:Firebase 正在显示带宽使用情况。
【问题讨论】:
-
你确定不应该是
console.log(this.state.records)吗?
标签: reactjs firebase redux firebase-realtime-database rebase