Getting data from the collection() query with useFirestoreConnect
after getting particular doc() causes multiple renders #914
Description
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
When I'm using useFirestoreConnect
to get the data from collection, that was previously provided to store user profiles (as userProfile
option), I'm facing a very strange behavior, that seems like a bug. My component is being continuously updated, adding one new element to collection state after each iteration, while isLoaded
is true
from the very beginning.
Here is the code:
export const Authors: React.FC<Props> = (props) => {
useFirestoreConnect(
[{
collection: 'users',
storeAs: "authors"
}]
)
const users = useSelector((state:AppState) => state.firestore.ordered.authors)
console.log(users, isLoaded(users));
return (
<div>
</div>
);
};
What is the expected behavior?
If I change collection to any other, that is not related to user profile, I meet the expected behavior:
UPDATE: If I remove profile definition from config, the same code also works as expected, so it's definitely a bug related to profile
and useFirestoreConnect
:
const rrfConfig = {
userProfile: 'users',
useFirestoreForProfile: true
}
UPDATE 2: I see a bunch of DOCUMENT_ADDED actions in my Redux console., so it's thinking that i'm adding those documents into my collection at the same time while i'm actually requesting them:
UPDATE 3
I have found, that this bug is not related to profiles only, but to any situation, when you first connect the particular doc, and then query all the collection. See my comment.
Which versions of dependencies, and which browser and OS are affected by this issue? Did this work in previous versions or setups?
{
"firebase": "^7.13.1",
"react": "^16.13.1",
"react-redux": "^7.2.0",
"react-redux-firebase": "^3.3.0",
"redux": "^4.0.5",
"redux-firestore": "^0.13.0",
}