【发布时间】:2019-02-16 19:06:38
【问题描述】:
我正在使用react-redux-firebase 的fireStoreConnect() 中间件与
我的 react-native 移动应用程序中的一个屏幕。在将组件连接到 redux 商店时,我想指定我连接到的 firestore 子集合,这取决于正在导航应用程序的用户。
我应该如何指定firestoreConnect 中的集合?用户 id 在 redux 存储中。
MWE:
import React, { Component } from 'react';
import { View, Text } from 'react-native';
import { compose } from 'redux';
import { connect } from 'react-redux'
import { firestoreConnect } from 'react-redux-firebase';
class PhotosScreen extends Component {
render() {
return (
<View>
<Text> i plan the use this.props.images here </Text>
</View>
);
}
}
const mapStateToProps = (state) => {
// reference the subcollection of the user
const images = state.firestore.data.images;
return {
images: images,
}
}
export default compose(
firestoreConnect([
{
collection: 'users',
doc: "HOW DO I GET THE USERS ID HERE? IT IS IN REDUX STORE",
subcollections: [{ collection: 'images' }]
}
]),
connect(mapStateToProps),
)(PhotosScreen)
【问题讨论】:
-
你使用的是什么版本的
react-redux-firebase?
标签: redux react-redux google-cloud-firestore react-redux-firebase