0
我試圖在我的firebase查詢中使用asyncStorage中的值。使用異步存儲的Firebase查詢
我對此感到困惑。我嘗試了異步/等待,然後嘗試/捕獲。
不知道我該怎麼做。
constructor(props) {
super(props);
this.state = {
dataSource: new ListView.DataSource({
rowHasChanged: (row1, row2) => row1 !== row2,
}),
};
const user = firebase.auth().currentUser;
if (user != null) {
AsyncStorage.getItem('parentUid')
.then((data) => {
this.setState({ pUID: data });
});
this.itemsRef = this.getRef().child(`Stores/${this.state.pUID}/`);
} else {
Alert.alert('Error', 'login again!');
}
this.connectedRef = firebase.database().ref('.info/connected');
}