Javascript 在react native-RangeError中从firebase firestore数据库中提取firestore映像:超过最大调用堆栈大小

Javascript 在react native-RangeError中从firebase firestore数据库中提取firestore映像:超过最大调用堆栈大小,javascript,react-native,firebase-storage,Javascript,React Native,Firebase Storage,我试图使用react native从firebase firestore数据库获取图像,但收到RangeError:超出最大调用堆栈大小错误,我无法理解其目的。我尝试过许多解决方案,但似乎没有一个对我有效。我的代码如下: //Function being called: getPostImage = (post) => { return firebase.storage().ref(`photos/${post.uid}/${post.timestamp}.jpg`).getD

我试图使用react native从firebase firestore数据库获取图像,但收到RangeError:超出最大调用堆栈大小错误,我无法理解其目的。我尝试过许多解决方案,但似乎没有一个对我有效。我的代码如下:

//Function being called:
  getPostImage = (post) => {
    return firebase.storage().ref(`photos/${post.uid}/${post.timestamp}.jpg`).getDownloadURL();
  };
...
//Calling the function in the image component:
<Image source={this.getPostImage(post)} style={styles.postImage} resizeMode="cover" />
//正在调用的函数:
getPostImage=(post)=>{
返回firebase.storage().ref(`photos/${post.uid}/${post.timestamp}.jpg`);
};
...
//调用图像组件中的函数:

我不知道该怎么办,所以非常感谢您的帮助。提前谢谢你

从API文档中可以看到,它是异步的,并返回一个用URL而不是URL本身解析的承诺。您必须等待它,或者使用然后来获取它的值。

而不是直接调用方法源,您可以这样做:

首先调用async方法,并在时间间隔内使用静态图像显示图像,以及图像何时可用显示该图像

//正在调用的函数:
getPostImage=异步(post)=>{
const imageUrl=await firebase.storage().ref(`photos/${post.uid}/${post.timestamp}.jpg`)。getDownloadURL();
这是我的国家({
下载图像:图像URL
});
};
...
//调用图像组件中的函数:

一旦我实现了这段代码,我就会收到一条警告,提示“image”提供了一个无效的“source”。我该怎么解决这个问题?谢谢你的帮助!您是否已使用静态图像替换了
localImagePlaceholder.png
?是的,我已将图像替换为其正确的url。我已设法消除了主要错误,但现在没有显示图像。我没有警告,只是在图片应该出现的空白处。事实上,在构建代码之后,这个答案似乎有效!谢谢你的帮助!我理解。您知道如何实现这个“.then()”语句吗?因为当我尝试在imageUrl上实现它时,它将状态设置为递归函数。