Open
Description
This is my first time posting a problem here, so if I'm doing something wrong, sorry!
I'm getting this error and I don't quite get it.
Here I am again with a problem I can't solve ! I'm getting this error and I don't quite get it.
enter image description here
After opening the DOM and reading the whole error and a lot of hours spend on Google, the only thing I got was that it looks like the error is triggered by this line of code:
const [user, setUser] = useState(null)
This is the Code where this line is :
import React, { useState, useEffect } from 'react';
import { StyleSheet, View, Text, Image, FlatList } from 'react-native';
import { connect } from 'react-redux';
import firebase from 'firebase';
require('firebase/firestore');
function Profile(props) {
const [userPosts, setUserPosts] = useState([]);
const [user, setUser] = useState(null);
useEffect(() => {
const { currentUser, posts } = props;
console.log({ currentUser, posts });
if (props.route.params.uid === firebase.auth().currentUser.uid) {
setUser(currentUser);
setUserPosts(posts);
}
});
if (user === null) {
return <View />;
}
return (
<View style={styles.container}>
<View style={styles.containerInfo}>
<Text> {user.name} </Text>
<Text> {user.email} </Text>
</View>
<View style={styles.containerGallery}>
<FlatList
numColumns={3}
horizontal={false}
data={userPosts}
renderItem={({ item }) => (
<View style={styles.containerImage}>
<Image style={styles.image} source={{ uri: item.downloadURL }} />
</View>
)}
/>
</View>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
marginTop: 40,
},
containerInfo: {
margin: 20,
},
containerGallery: {
flex: 1,
},
containerImage: {
flex: 1 / 3,
},
image: {
flex: 1,
aspectRatio: 1 / 1,
},
});
const mapStateToProps = (store) => ({
currentUser: store.userState.currentUser,
posts: store.userState.posts,
});
export default connect(mapStateToProps, null)(Profile);
I'm making an Instagram Clone and if you need any other code I have, please tell me because I don't know what you all need to help me.