title: × TypeError: Cannot read properties of undefined (reading 'uid')
body: <p>So I'm getting this error and I don't get why I used the same hook and method on the profile file and it's working just fine but with the feed it's different and I don't know why.</p>
  <p>I'm trying to get the username of the person that created the post, I only managed it to get the username of the current user logged in but not the user that made the post</p>
  <p><a href="https://i.stack.imgur.com/9jmmF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9jmmF.png" alt="enter image description here" /></a></p>
  <p>The code:</p>
  <pre><code>import React, { useState, useEffect } from &quot;react&quot;;
  import {
    StyleSheet,
    View,
    Text,
    Image,
    FlatList,
    Button,
    ScrollView,
  } from &quot;react-native&quot;;
  import { connect } from &quot;react-redux&quot;;
  import { useAllPosts } from &quot;../../hooks/Posts&quot;;
  import { useUser } from &quot;../../hooks/Users&quot;;
  import { makeStyles } from &quot;@material-ui/core/styles&quot;;
  import Avatar from &quot;@material-ui/core/Avatar&quot;;
  import Divider from &quot;@material-ui/core/Divider&quot;;
  import firebase from &quot;firebase/app&quot;;
  import &quot;firebase/firestore&quot;;
  import &quot;firebase/auth&quot;;
  import { Typography } from &quot;@material-ui/core&quot;;
  
  const useStyles = makeStyles({
    avatar: {
      marginLeft: 15,
      marginTop: 15,
      marginBottom: 5,
    },
    text: {
      marginTop: 20,
      marginLeft: 15,
      fontStyle: &quot;bold&quot;,
    },
  });
  function Feed(props) {
    const user = useUser(props.route.params.uid);
    const classes = useStyles();
    const posts = useAllPosts(firebase.auth().currentUser.uid);
  
    return (
      &lt;ScrollView style={styles.root}&gt;
        &lt;FlatList
          numColumns={1}
          horizontal={false}
          data={posts}
          renderItem={({ item }) =&gt; (
            &lt;View style={styles.containerImage}&gt;
              &lt;Image
                style={styles.image}
                key={item.downloadURL + `?${new Date()}`}
                source={{ uri: item.downloadURL }}
              /&gt;
              &lt;View style={styles.container}&gt;
                &lt;Avatar className={classes.avatar}&gt;&lt;/Avatar&gt;
                &lt;Typography className={classes.text}&gt;{user?.name}&lt;/Typography&gt;
              &lt;/View&gt;
              &lt;Text style={styles.containerInfo}&gt;{item.caption}&lt;/Text&gt;
              &lt;Divider /&gt;
            &lt;/View&gt;
          )}
        /&gt;
      &lt;/ScrollView&gt;
    );
  }
  const styles = StyleSheet.create({
    root: {
      backgroundColor: &quot;white&quot;,
    },
    container: {
      display: &quot;flex&quot;,
      width: &quot;100%&quot;,
      flexDirection: &quot;row&quot;,
      justifyContent: &quot;flex-start&quot;,
    },
  
    containerInfo: {
      marginTop: 20,
      marginLeft: 15,
      marginBottom: 10,
      fontSize: 20,
    },
    // containerGallery: {
    //   flex: 1,
    // },
    containerImage: {
      marginTop: 15,
      marginBottom: 30,
    },
    image: {
      resizeMode: &quot;cover&quot;,
      aspectRatio: 1 / 1,
    },
  });
  
  const mapStateToProps = (store) =&gt; ({
    currentUser: store.userState.currentUser,
    following: store.userState.following,
    users: store.usersState.users,
    usersLoaded: store.usersState.usersLoaded,
  });
  
  export default connect(mapStateToProps, null)(Feed);
  </code></pre>