Профиль response-redux-firebase запрещает firestore добавлять пользовательский документ - PullRequest
0 голосов
/ 21 июня 2020
• 1000 выдает даже ошибку, просто останавливайтесь, и когда я удаляю конфигурацию профиля, она работает. Я читал react-redux-firebase, но до сих пор понятия не имел, что происходит
//index.js


const rrfConfig = {
  userProfile: 'users',
  useFirestoreForProfile: true, // Firestore for Profile instead of Realtime DB
  // enableClaims: true // Get custom claims along with the profile
};
//authAction.js


export const normalSignup = (cerdentials) => {
  return (dispatch, getState, { getFirebase }) => {
    const firebase = getFirebase();
    const firestore = getFirebase().firestore();
    const { email, username, password } = cerdentials;
    firebase
      .auth()
      .createUserWithEmailAndPassword(email, password)
      .then((res) => {
        firestore // this part stop working when adding the Profile configuration
          .collection('users')
          .doc(res.user.uid)
          .set({ email, username, type: 'User', createdAt: new Date().toISOString() })
          .then((res) => {
            console.log(res);
          })
          .catch((err) => {
            console.log(err);
          });
      })
      .then((res) => {
        console.log(res);
        dispatch({ type: 'SIGNUP_SUCCESS' });
      })
      .catch((err) => {
        dispatch({ type: 'SIGNUP_ERROR', err });
      });
  };
};
//authReducer.js


const initState = {};

const authReducer = (state = initState, action) => {
  switch (action.type) {
    case 'SIGNUP_ERROR':
      console.log(action.err);
      return state;

    case 'SIGNUP_SUCCESS':
      console.log('signup is successful');
      return state;

   
    default:
      return state;
  }
};
...