【发布时间】:2021-02-16 05:09:47
【问题描述】:
我尝试使用钩子显示来自 S3 的图像。
我一直收到错误“source.uri 不应为空字符串”
我不知道我在这里错过了什么。
下面是我的代码
const [img9, setImg9] = useState("");
const updateImgURL = async (img) => {
console.log("into get s3");
await Storage.get(img).then((data) => {
setImg9(JSON.stringify(data));
});
};
useEffect(() => {
updateImgURL(m9_9_img);
}, []);
////////////////////////////////
<Image
style={{ height: 200, width: screenWidth / 3 + 20, borderWidth: 1 }}
source={{
uri: img9,
}}
/>
fyi m9_9_img 是我从上一个屏幕对象中获得的值。我已经做了控制台日志,看起来数据已设置到 img9 但它仍然不会显示。谁能帮我解决这个问题?
【问题讨论】:
标签: react-native amazon-s3 aws-amplify