【发布时间】:2021-03-27 08:50:05
【问题描述】:
我认为在我的代码中我以某种方式循环浏览图像,但我的 console.log 确实很疯狂。我每个文件夹中只有 3 张图片。一个叫back,另一个叫front。我怎样才能让它显示所有图像而不会导致应用程序停止爬行。同样,每个文件夹中只有 3 张图片。
为了简洁起见,我只发布其中一个。
const [frontImage, setFrontImage] = useState();
const getFrontImage = async () => {
var user = firebase.auth().currentUser.email;
// like this right here gets put out almost 50 times
console.log(user + "this is name");
const imageRefs = await firebase.storage().ref().child(user + '/FrontPic/').listAll();
const urls = await Promise.all(imageRefs.items.map((ref) => ref.getDownloadURL()));
setFrontImage(urls);
}
useEffect(() => {
getFrontImage();
});
稍后在此处调用图像
<View style={styles.DisplayImageWith}>
{frontImage && frontImage.map(url => (
<View style={{ justifyContent: 'center' }} key={url}>
<Image source={{ uri: url }} style={{ width: 150, height: 150 }} />
</View>
))}
</View>
【问题讨论】:
-
在此处发布之前尝试创建最小的可重现示例。我认为这与firestore完全无关
标签: javascript reactjs firebase react-native firebase-storage