Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

293
Visualizações
TypeError: null is not an object (evaluating 'user.uid') React Native FireBase

The user.uid I pulled from the AuthContext and the useContext gives such an error. Basically i will let the shared post delete if the userid is equal to the logged in. but user.uid == post.userId this is not working and it's error :TypeError: null is not an object (evaluating 'user.uid') How to fix it ?

import { AuthContext } from "../../Pages/AuthProvider/AuthProvider";
const PostCard = ({post}) => {
    const {user} = useContext(AuthContext); 
    const userID=user.uid;
    return(
        <View style={styles.container}>
            <View style={styles.header}>
                <View style={styles.inner1_container}>
                    <Image
                        style={styles.profile_image}
                        source={ProfileImg}
                    />
                    <Text style={styles.username_text}>username</Text>
                </View>
                <View style={styles.inner2_container}>
                    <Text style={styles.like_text}>Patileyenler: {post.likes}</Text>
                    <View style={styles.like_button}>
                    <TouchableWithoutFeedback
                        onPress={liked}
                    >
                        <Image
                            style={styles.like_button_image}
                            source={isLiked ? likedPaw : unLikedPaw}
                        />
                    </TouchableWithoutFeedback>
                    </View>
                </View>                
            </View>

            <View style={styles.describe_container}>
                <Text numberOfLines={8} style={styles.describe_text}>{post.descreption}</Text>
                {
                    post.contact != "" && (<>
                        <Text numberOfLines={2} style={styles.contact_text}>{iltetisimtext}{post.contact} </Text>
                    </>) 
                }
                <Text style={styles.time_text}>Paylaşma Zamanı</Text>
                {
                    user.uid == post.userId && (<>
                    <Text style={styles.time_text}>Delete</Text>
                    </>)
                }
            </View>
        </View>        
    )
}

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The reason for the error was that the user object was null when we logged out. I checked this with if and resolved the error.

    function deletePostText(){
        if(user){
            if(user.uid == post.userId){
                 return(
                    <TouchableOpacity>
                        <Text style={styles.time_text}>Delete</Text>
                    </TouchableOpacity>
                )
            }
           }
        else{
            return;
        }
    }  

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda