首页 > 解决方案 > React Native从firebase存储下载多个图像

问题描述

我有这段代码,我在其中下载了渲染项中的照片,然后将它们显示在屏幕上,当我显示单个图像时它可以正常工作,但是当我尝试显示多个图像时,会创建无限查询循环并且应用程序停止在职的。渲染项显示在平面列表中

const [imageUrl, setImageUrl] = useState(undefined);
const renderItem = ({item}) =>{
  let correo = item.correo;
  storage
    .ref(item.correo+"/"+ item.titulo)
    .getDownloadURL()
    .then((url) => {
      setImageUrl(url);
      console.log(url);
    })
    .catch((e) => console.log('Errors while downloading => ', e));
return(
<Image
     source={{ uri: imageUrl }}
     style={{
     width: 113,
     height: 99,
     borderTopLeftRadius: 10,
     borderBottomLeftRadius: 10,
     }}
   />
)
}

标签: react-nativefirebase-storage

解决方案


推荐阅读