Reputation:
I am retrieving images from Firestore but it shows this in image area. I cannot solve this problem.
Method:
useLayoutEffect(() => {
const unsubscribeimage = db
.collection("token")
.onSnapshot((snapshot) =>
setPhoto(
snapshot.docs.map((doc) => ({
id: doc.id,
dataimg: doc.data(),
}))
)
);
return unsubscribeimage;
}, []);
My return code:
<View { photo.map(({dataimg,id }) =>
<View style={styles.sender} key={id}>
<Avatar source={{uri: dataimg}} style={{ width: 200, height: 200 }} />
</View>
I am fetching this image:
Upvotes: 0
Views: 744
Reputation: 85201
dataimg: doc.data()
doc.data()
is going to return the entire document object, which in this case looks like:
{
imageURL: "https://**etc*",
}
So later when you do source={{uri: dataimg}}
, uri
is the entire object, not just the uri. Instead you need to do source={{uri: dataimg.imageURL}}
.
Upvotes: 1