问题
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