【发布时间】:2019-11-20 06:04:09
【问题描述】:
我实际上想在包含多个文档的 firestore 中迭代一个集合,并且我想返回包含等于我的 uid 的字段 uid 的文档。
这是firestore中的数据:
const { user } = this.props ;
console.log("getting user data: ", user )
这是我的代码:
render() {
const auth = this.props.auth;
console.log("getting user id: ", auth.uid);
const userData = user.map((item)=>(
(item.uid) = (auth.uid)
? <Text color="white" size={28} style={{ paddingBottom: 8 }}>
{ item.displayName } </Text>
: <Text color="white" size={28} style={{ paddingBottom: 8 }}> Error
</Text>
)
);
return (
<Block style={styles.profileTexts}>
{userData}
</Block>
)
}
const mapStateToProps = ( state ) => {
console.log("state firebase",state);
return{
auth: state.firebase.auth,
user: state.firestore.ordered.users,
}
}
const mapDispatchToProps = (dispatch) => {
return {
signOut: () => dispatch(signOut()),
}
}
export default compose(
connect(mapStateToProps, mapDispatchToProps),
firestoreConnect([
{ collection: 'users'},
]))(Profile)
但是我收到了这个错误: "TypeError: undefined is not an object (evalating 'o.map')"
【问题讨论】:
标签: reactjs firebase react-native google-cloud-firestore