How to access Firestore subcollections with react-redux-firebase

I would like to share with you a code snipped of how to access subcollections in the Cloud Firestore database.
Lets say we have this structure:
- Users
|
-- Tasks
Our exercise is to access the tasks list of a certain user.
import { compose } from "redux";
import { connect } from "react-redux";
import { firestoreConnect } from "react-redux-firebase";
...
const enhance = compose(
firestoreConnect(props => {
return [{ collection: "users", doc: props.uid, subcollections: [{ collection: "tasks" }], storeAs: `${props.uid}-tasks` }];
}),
connect(({ firestore }, props) => {
return {
tasks: firestore.ordered[`${props.uid}-tasks`] || []
};
})
);
...
const Tasks = ({ firestore, tasks }) => {
return <YOUR_TASKS_LIST_UI>
}
export default enchance(Tasks)
It's really that simple!
Happy coding! 👨💻