问题
I'm making a call to firestore with an array of member ids - looking to get back the photoURL property for each and render via jsx. I checked memberAvatars and it's returning fine, but I get this error:
Error: Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead.
Here is the code I'm using. It is meant to render each cell in an ant table using their render prop.
async getMemberAvatars(members) {
let memberAvatars = [];
const urls = members.map(async userId => {
const doc = await db
.collection("users")
.doc(userId)
.get();
memberAvatars.push(doc.data().photoURL);
});
await Promise.all(urls);
let jsx = memberAvatars.map(url => <Avatar src={url} />);
return jsx;
}
来源:https://stackoverflow.com/questions/59473492/using-async-await-in-firebase