React native 使用映射函数异步等待,promise.all不工作

React native 使用映射函数异步等待,promise.all不工作,react-native,promise,expo,React Native,Promise,Expo,我正在使用expo和react native构建一个应用程序 我正在尝试使用async await和带有Promise的map函数从firebase加载照片。但我得到的只是一系列未解决的承诺 renderImages = async () => { const images = []; if (this.state.images.length > 0) { images = this.state.images.map(async (item, index) =>

我正在使用expo和react native构建一个应用程序

我正在尝试使用async await和带有Promise的map函数从firebase加载照片。但我得到的只是一系列未解决的承诺

renderImages = async () => {
  const images = [];

  if (this.state.images.length > 0) {
    images = this.state.images.map(async (item, index) => {
      const ref = firebase.storage().ref(item);

      var image = await ref.getDownloadURL();

      return (
        <View>
          <Image source={{ uri: image }} />
        </View>
      );
    });

    const imageArray = await Promise.all(images);

    return imageArray || [];
  }

  return (
    <View>
      <Text>STATE.IMAGES.LENGTH is 0</Text>
    </View>
  );
};

好的,所以我不知道
async/await
总是返回一个
promise

我通过添加这个来处理这个问题

onRenderImages() {
  this.renderImages().then(data => {
     this.setState({ 
         displayImages: data
     })
  })
}

这看起来不像承诺数组,它看起来像承诺。是的,
renderImages
是一个
异步函数
,因此它当然会返回一个承诺。一切似乎都在运转。你能告诉我们你在哪里调用函数的代码,以及你在哪里“得到”结果吗?啊,就像怀疑的那样。
onRenderImages() {
  this.renderImages().then(data => {
     this.setState({ 
         displayImages: data
     })
  })
}