下面的行指向firestoreConnect
我的收藏,标签为projects
。
{ collection: 'projects' }
当项目集合立即位于根目录下时,它可以工作,如下所示:
root/
projects/
但是,如果项目集合被本身位于另一个集合中的文档引用,例如,像这样:
root/
users/
alice/
projects/
我如何指向firestoreConnect
集合projects
?
import React, { Component } from 'react'
import ProjectList from '../projects/ProjectList'
import Notifications from './Notifications'
import { connect } from 'react-redux'
import { firestoreConnect } from 'react-redux-firebase'
import { compose } from 'redux'
import { Redirect } from 'react-router-dom'
class Dashboard extends Component {...}
const mapStateToProps = (state) => {
// console.log(state);
return {
projects: state.firestore.ordered.projects,
auth: state.firebase.auth,
}
}
export default compose(
connect(mapStateToProps),
firestoreConnect([
{ collection: 'projects' }, // <-- Question is about this line
])
)(Dashboard)
编辑:不成功的尝试
从我可以从这里的评论中拼凑出来的答案似乎是:
firestoreConnect([
{
collection : 'users',
doc : 'alice',
collection : 'projects',
}
])
但这种尝试失败了。