question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug(reducers): multiple subcollections on same parent collection causes invalid merge

See original GitHub issue

Here’s the scenario. This is React code with a router and I have two components on two different pages doing:

  firestoreConnect([
    { collection: 'group', doc: 'uJH3akkXRkje3ruPZ7au' },
    {
      collection: 'group',
      doc: 'uJH3akkXRkje3ruPZ7au',
      subcollections: [{ collection: 'objects' }],
    },
  ]),

And the other one doing

firestoreConnect(['group'])

Whenever I go from the first component to the second component,firestoreConnect on group would shallow merge the specific doc and removing the subcollection information stored in there, both on dataReducer and orderedReducer.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Klabautermancommented, Jan 11, 2018

I have the same issue even in 0.2.5. It is also a problem if you have two subcollections in the same parent document. Both are updating the parent document and the second subcollection update removes the data of the first one from the store-state. Maybe I could use storeAs as a workaround, but I think that is not a good solution.

1reaction
prescottpruecommented, Dec 14, 2017

@diagramatics Good to know. If you need a solution in the meantime you can use storeAs to place the data in different locations of redux and merge the data by hand.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Firebase Query Collection And Merge Subcollection Data
First you get all the parent documents and at the same time you use Promise.all() to query, in parallel, all the 'historic' sub-collections....
Read more >
akita-state-management/Lobby - Gitter
This means that you have to retrieve subcollection data from the server everytime you go back an forth between items in the parent...
Read more >
redux-firestore: Versions | Openbase
fix(reducer): correctly update data state by no longer merging - #45, ... multiple subcollections on same parent collection correctly merges doc data -...
Read more >
Error: Collection can only be run on a document #192 - GitHub
Hi @prescottprue so I provided a parent doc reference when listing subcollections but got same error, when subcollection doesn't exists or ...
Read more >
https://www.pewtrusts.org/assets/pew/js/libraries-...
isNativeReflectConstruct.js\");\n\nfunction _construct(Parent, args, Class) {\n if ... + 'Tried to merge two objects with the same key: `%s`.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found