SimCoderYoutube/InstagramClone

Issue getting uid using getState from redux

OyeMoeed opened this issue · 0 comments

`export function fetchUsersData(uid, getPosts) {
return (dispatch, getState) => {
const found = getState().usersState.users.some(el => el.uid === uid);
if (!found) {
firebase
.firestore()
.collection('Users')
.doc(uid)
.get()
.then(snapshot => {
if (snapshot.exists) {
let user = snapshot.data();
user.uid = snapshot.id;

        dispatch({type: USERS_DATA_STATE_CHANGE, user});
      }
    });
  if (getPosts) {
    dispatch(fetchUsersFollowingPosts(uid));
  }
}

};
}

export function fetchUsersFollowingPosts(uid) {
return (dispatch, getState) => {
firebase
.firestore()
.collection('posts')
.doc(uid)
.collection('uploads')
.orderBy('creation', 'asc')
.get()
.then(snapshot => {
const uid = snapshot.docs[0].ref.path.split('/')[1];
const user = getState().usersState.users.find(el => el.uid === uid);

    let posts = snapshot.docs.map(doc => {
      const data = doc.data();
      const id = doc.id;
      return {id, ...data, user};
    });
    dispatch({type: USERS_POST_STATE_CHANGE, posts, uid});
  });

};
}`

ERROR TypeError: relativePath.split is not a function (it is undefined), js engine: hermes
can you guide me about this error?