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 559 forks source link

Basic Populate Parameters users not working for me. #887

Open francisleigh opened 4 years ago

francisleigh commented 4 years ago

I am working with React native


Hello, I am following these steps http://react-redux-firebase.com/docs/recipes/profile.html#populate-parameters but can't seem to get the described output.

"react-redux-firebase": "^3.1.2",

const rrfConfig = {
    userProfile: "users",
    profileParamsToPopulate: ["contacts:users"],
};

My realtime database structure looks like this:

Screenshot 2020-03-21 at 21 00 06

But when i log contacts on my page (when i am logged in as francis100@test.com i just get the raw contacts array with Georgia's user ID inside it. I would expect to get:

[
    {
      email: 'G@g.com',
    }
]

but get: ["WaA5NpF8m2gaaeKnXI8tkYcCdR13"]

The component i log contacts from is connected to firebase via redux's connect

connect(({ firebase }) => ({
    contacts: firebase.profile.contacts,
}))(Component);

I hope i'm just missing a step and this is just me being a firebase & react-redux-firebase noob. :-)

Thank you!

prescottprue commented 4 years ago

@FrancisLeigh You still need to use populate when pulling data out of redux. profileParamsToPopulate just creates the listeners for the necessary data to go into redux. Like so:

export const profilePopulates = [{ child: 'contacts', root: 'users' }]
const config = {
  userProfile: 'users',
  profileParamsToPopulate: profilePopulates
}

// Then later
connect(({ firebase }) => ({
  profileWithContacts: populate(firebase, 'profile', profilePopulates),
}))(Component);

This is described in the populate role example within the recipes section of the docs.