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');
}