prescottprue / react-redux-firebase

Redux bindings for Firebase. Includes React Hooks and Higher Order Components.
https://react-redux-firebase.com
MIT License
2.55k stars 556 forks source link

bug(helpers): isEmpty returns false for collections with only deleted docs #486

Open matt-tingen opened 6 years ago

matt-tingen commented 6 years ago

Do you want to request a feature or report a bug?

Bug?

What is the current behavior?

isEmpty returns false for collections with only deleted docs e.g. { id1: null, id2: null }

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.

Create a list component connected to firestore which changes its render when the collection is empty. Delete all the docs from the collection.

What is the expected behavior?

isEmpty returns true for collections with only deleted docs. To avoid making a breaking change and still allow for e.g. animating of the deletion of the last item in a collection, it may make more sense to either:

  1. More explicitly document the current behavior
  2. Include an additional helper which functions the same as isEmpty except when operating on collections with only deleted docs.

Which versions of dependencies, and which browser and OS are affected by this issue? Did this work in previous versions or setups?

react-redux-firebase 2.1.4 MacOS 10.13 Chrome 66

prescottprue commented 5 years ago

This may be able to be added to isLoaded through a reduce that is checking for any non falsey values. The problem that may come up with that though is the loading a document with all falsey values or an object in RTDB which is all falsey values.

Open to ideas, but going to give this some thought before moving forward with a solution. Thanks for posting!