Do you want to request a feature or report a bug?
bug
What is the current behavior?
Trying with 2.0.0 latest version.
When trying to pass a set of child keys to populate if some of the keys does not exist in the firebase route none of the keys are populated.
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.
I have a /users/uid route in firebase which has only "experiences" key. If non existent childkeys are included in the populates list existing keys should still be populated.
Populate works fine when I try to initiate with
const populates = [
{ child: 'experiences', root: '/allExperiencesList' },
]
const fbWrappedComponent = firebaseConnect(
({AuthProfile}) => {
if(AuthProfile){
return ([{path: `/users/${AuthProfile ? AuthProfile.uid : ''}`, populates}])
}
}
)(TopBarContainer)
but fails if I add a key which does not exist and try as follows,
const populates = [
{ child: 'experiences', root: '/allExperiencesList' },
{ child: 'education', root: '/allEducationList' },
]
const fbWrappedComponent = firebaseConnect(
({AuthProfile}) => {
if(AuthProfile){
return ([{path: `/users/${AuthProfile ? AuthProfile.uid : ''}`, populates}])
}
}
)(TopBarContainer)
Tried enabling logging to "true" and clearly see that populate is not even triggered in the second case.
Which versions of dependencies, and which browser and OS are affected by this issue? Did this work in previous versions or setups?
As far as I know it did work in previous versions.
Going to attempt to replicate, but a few things that stick out initially from your examples:
connect, you will never be getting this data out of redux (maybe it got left out of the example or I missed something?)AuthProfiledoesn't exist, then nothing is returned to firebaseConnect, which means that no queries will be createdroot values shouldn't need / as a prefix (could cause issue, not sure)Unrelated Side Note: May be totally wrong but, I believe that capitalizing prop names is seen as frowned upon
Thanks Scott.
2,3. This component indeed is launched only for logged in users
Also will look at de-capitalising the prop names if that is standard approach.
If the component only shows for authenticated users, is the if statement within the firebaseConnect necessary (assuming AuthProfile prop) carries the auth. That could keep queries from being created.
Other than that, still need to replicate.
No that is surely not needed. Was trying various things and it must have been left behind. I see same behaviour even without that check.
From: Scott notifications@github.com
Sent: Wednesday, September 20, 2017 5:55:36 PM
To: prescottprue/react-redux-firebase
Cc: raghavendracs; Author
Subject: Re: [prescottprue/react-redux-firebase] Problem with Populates when childkey does not exist (#277)
If the component only shows for authenticated users, is the if statement within the firebaseConnect necessary (assuming AuthProfile prop) carries the auth. That could keep queries from being created.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubhttps://github.com/prescottprue/react-redux-firebase/issues/277#issuecomment-330914494, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AKCvftM-TXPZ3ahQqsPc9iMQ4kockiM5ks5skUOIgaJpZM4PdKCg.
@raghavendracs Is it possible for you to include the full example (including those connect snippets) so that the issue can be replicated?
Are you attempting to populate your own user profile? If so, it would take using profileParamsToPopulate along with populate.
@raghavendracs Would love to reproduce the bug so it can get fixed. Any way you can post your full example?
Sure Scott. Will pull out the relevant code from my repo and post.
Best Regards,
Raghu
+44 7470 123 259
From: Scott notifications@github.com
Sent: Tuesday, September 26, 2017 7:45:23 AM
To: prescottprue/react-redux-firebase
Cc: raghavendracs; Mention
Subject: Re: [prescottprue/react-redux-firebase] Problem with Populates when childkey does not exist (#277)
@raghavendracshttps://github.com/raghavendracs Would love to reproduce the bug so it can get fixed. Any way you can post your full example?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/prescottprue/react-redux-firebase/issues/277#issuecomment-332102307, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AKCvfojsTwK6kD0yJlaEw1va5Cxnp7rTks5smJ2DgaJpZM4PdKCg.
I am able to reproduce it on v2.
This is my config:
export const profilePopulateSettings = [
{ child: 'neighborhood', root: 'neighborhoods' },
{ child: 'directMessages', root: 'directMessages' },
];
Each user has his neighborhood, but not all of them have direct messages.
Something like:
users: {
user1: {
neighborhood: <key>,
directMessages: <optional object>
}
}
I pass that into a reactReduxFirebase as a config:
const config = {
userProfile: 'users', // firebase root where user profiles are stored
enableLogging: false, // enable/disable Firebase's database logging
profileParamsToPopulate: profilePopulateSettings,
};
Then in my container I have something like that:
connect(
state => ({
auth: state.firebase.auth,
profile: populate(state.firebase, 'profile', profilePopulateSettings) // third argument does not matter,
}),
),
If user has both neighborhood and directMessages then profile is populated. If directMessages are missing there's nothing populated - even non-empty neighborhood.
Profile gets populated only if both properties exist.
Expected - profile.neighborhood is expanded, directMessages stay empty.
@pzmudzinski thanks for pointing out a easy to reproduce case. Going to look into this later this week, but always open to PRs.
Fix was included as part of v2.0.0-beta.11.
Shout out to @jeremyplease for the PR that fixed it