Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Im trying to add documents that's in a sub-collection. Like this:
export const addActionCard = () => {
return (dispatch, getState, { getFirestore }) => {
// make async call to database
const firestore = getFirestore();
firestore.collection('retros').doc('oiWiKlsrI7Q2LqNXVaSA').collection('cardsAction').add({
authId: '1337',
content: 'this is a action card'
}).then(() => {
dispatch({ type: 'CREATE_CARD_SUCCESS' });
}).catch(err => {
dispatch({ type: 'CREATE_CARD_ERROR' }, err);
});
}
};
And this is how I get the data with firestoreConnect:
const mapStateToProps = (state, ownProps) => {
console.log(state);
return {
retro: state.firestore.ordered.retros,
cards: state.firestore.ordered.actionz
}
}
export default compose(
firestoreConnect((props) => [
{ collection: 'retros', doc: props.match.params.retroId },
{ collection: 'retros', doc: props.match.params.retroId, subcollections: [{ collection: 'cardsAction', }],
storeAs: 'actionz' },
]),
connect(mapStateToProps, mapDispatchToProps)
)(RetroDetails)
_The doc's are added properly in the Firebase Console_ _But my firestore state is not updating correctly_. All the document id's gets undefined EXCEPT the first one after checking firestore.ordered.
But if I hard refresh the browser they all get their ids.
This is how it looks:

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via codesandbox or similar.
URL: https://wz6j0lj54k.codesandbox.io/retro/oiWiKlsrI7Q2LqNXVaSA
Source files: https://codesandbox.io/s/wz6j0lj54k
Which versions of dependencies, and which browser and OS are affected by this issue? Did this work in previous versions or setups?
"firebase": "^5.8.1",
"moment": "^2.24.0",
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-redux": "^6.0.0",
"react-redux-firebase": "^3.0.0-alpha.6",
"react-router-dom": "^4.3.1",
"react-scripts": "2.1.3",
"redux": "^4.0.1",
"redux-firestore": "^1.0.0-alpha.2",
"redux-thunk": "^2.3.0"
Try using storeAs or upgrading to the newer version of redux-firestore available through the alpha tag to store the subcollection outside of the document. I believe this is a duplicate of 140 of redux-firestore.
Thanks for the reply @prescottprue :)
If you looked at my code I am using both storeAs and have the latest redux-firestore trough the alpha tag, Im also storing the subcollection outside of the document. This is why I wrote this issue.. because I have already gone trough the documentations and other issues people had. But maybe I'm missing something..
@jalvarson The newest version of redux-firestore has a different api as noted in the v1.0.0 roadmap, but your case should work since as you noted you provided storeAs and you showed how it shows up in the right part of state.
It is really interesting that there aren't ids accept on the newest one, thanks for reporting!
It is really interesting that there aren't ids accept on the newest one, thanks for reporting!
I cant get my head around it @prescottprue. Feel's like I have tried every possible solution.. :( Working with sub-collections they way it says in the documentation. But deleting/adding/update document's to a collection works great tough.
I also think i have posted this wrong. Should have placed it in redux-firestore ?
@prescottprue I can confirm that this problem was made by the newer version of redux-firestore trough the alpha tag. I downgraded the version to 0.6.3 and now everything works. The problem with all the documents id's in a subcollection being undefined, is now working?
How can that be?! :O
@jalvarson Very weird, no idea! 馃槅 Either way, thanks for updating
I believe this is similar to 121 of redux-firestore even though the symptoms are slightly different. Going to close this issue and make updates on there. Thanks for reporting.
Most helpful comment
Thanks for the reply @prescottprue :)
If you looked at my code I am using both
storeAsand have the latestredux-firestoretrough the alpha tag, Im also storing the subcollection outside of the document. This is why I wrote this issue.. because I have already gone trough the documentations and other issues people had. But maybe I'm missing something..