Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make use of docChange of QuerySnapshot to pick changes #58

Open
valentinalexeev opened this issue Dec 4, 2019 · 0 comments
Open

Make use of docChange of QuerySnapshot to pick changes #58

valentinalexeev opened this issue Dec 4, 2019 · 0 comments

Comments

@valentinalexeev
Copy link

Is there an option for react-firebase to support delta change of QuerySnapshot to cherry-pick and update only the affected documents (added, modified, deleted) in the local copy?

  • react-firestore version: 1.0.1
  • node version: v8.16.0
  • npm (or yarn) version: 1.19.1

Relevant code or config

The current FirebaseCollection.handleOnSnapshotSuccess() is directly updating the state by replacing the data in case of even minor updates of the collection.

What you did:
MUI-Datatable wrapped in FirebaseCollection and data is shared between the components.

What happened:
Upon internal (from within the app) or external change of the data (another app user) the Datatable widget will re-render fully.

Problem description:
In case consumer widget is relying on state of data the component must re-render fully breaking the flow unexpectedly. In my app the FirebaseCollection feeds MUI-Datatable and change of underlying data re-renders the full table and loosing the state of the table.

Suggested solution:

  • Use docChange() and a different state management approach,
  • useReducer to delegate state management to consumer,
  • any other option?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant