react-redux-firebase not populating profile in firebase reducer

感情迁移 提交于 2019-12-13 08:44:40

问题


react-redux-firebase isn't populating user profle in firebase reducer even after a successful signIn width auth.signInWithEmailAndPassword method and data exist users/${uid}.As I'm storing data in firestore so I've configured react-redux-firebase as:

const reduxFirebaseConfig = {
  userProfile: 'users',
  attachAuthIsReady: true,
  useFirestoreForProfile: true,
  updateProfileOnLogin: false
};

Reducer in redux-dev-tool:

firebase > profile {isLoaded: false, isEmpty: true}. 

Note: Working with react-native so using it's firebase library (React-Native-firebase). Everything work perfectly except user profile in firebase reducer.


回答1:


Have you specified the profileFactory key for your reduxFirebaseConfig?

My reduxFirebaseConfig looks like:

const reduxFirebaseConfig = {
  userProfile: 'users',
  useFirestoreForProfile: true,
  enableRedirectHandling: false,
  resetBeforeLogin: false,
  profileFactory
};

and my profile factory looks like:

const profileFactory = (userData, profileData) => {
  let {
    email,
    firstName,
    lastName,
    companyId,
    department,
    division
  } = profileData;
  firstName = startCase(firstName);
  lastName = startCase(lastName);
  const username = `${firstName} ${lastName}`;
  const initials = `${firstName[0]}${lastName[0]}`;
  return {
    email: email,
    firstName,
    lastName,
    username,
    initials,
    department,
    division: division || '',
    companies: { [companyId]: true }
  };
};



回答2:


Question was added a long time ago, but i found the sollution: This only works for the users you created using your app form. Not the initial user you created inside Firebase as that one does not exists inside the "users" collection.



来源:https://stackoverflow.com/questions/55871931/react-redux-firebase-not-populating-profile-in-firebase-reducer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!