【发布时间】:2021-01-08 05:44:20
【问题描述】:
我有这个错误:
bundle.js:2066 Uncaught (in promise) TypeError: undefined is not iterable.
我的代码:
firebase.auth().onAuthStateChanged(user => {
if (user)
{
if (user.uid != null)
{
let storageRef = firebase.storage().ref("Users/" + user.uid);
console.log(storageRef)
storageRef.listAll().then( res => {
let promises = res.items.forEach( item => item.getDownloadURL() );
Promise.all(promises).then((downloadURLs) => {
this.setState({ urlImage: downloadURLs });
})
})
}
console.log(this.state.urlImage)
const actionPhoto = { type: "TOGGLE_PHOTO", value: this.state.urlImage };
this.props.dispatch(actionPhoto)
const actionUid = { type: "TOGGLE_UID", value: user.uid };
this.props.dispatch(actionUid)
// On ajoute le nom et la photo du current user
const actionName = { type: "TOGGLE_NAME", value: user.displayName };
this.props.dispatch(actionName)
//this.props.navigation.navigate('Navigation')
}
})
我在foreach(items) 和ref() 中有一项存储firebase 很好。
你有想法吗?
【问题讨论】:
标签: reactjs firebase react-native promise setstate