【发布时间】:2019-03-07 20:31:37
【问题描述】:
这就是我的数据库的样子:
-members
--L_C3OzCYFevhXzT5xk9 (specific key for Chat Room)
---user1: 'test@gmail.com'
---user2: 'test1@gmail.com'
我正在尝试从 Firebase 接收此特定密钥并将其设置为状态。这就是我尝试这样做的方式:
const query = firebase.database().ref('/members').orderByKey().equalTo(email);
query.once('value')
.then(function(snapshot) {
snapshot.forEach(function(childSnapshot) {
var key = childSnapshot.key;
this.setState({ChatID: key});
});
});
console.log(this.state.ChatID);
但每次我在 console.log 中收到“null” 我做错了什么?
【问题讨论】:
标签: javascript react-native firebase-realtime-database react-native-firebase