Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

861
Vistas
The correct way to delete a user with react-native-firebase from Auth and Firestore at once?

I'm trying to delete a user from Auth and Firestore on button click in one go using react-native-firebase. My issue at the moment is that it is not deleting the document 'user' from Firestore. BUT, it does look like I am deleting the user from Auth.

Also when I press the button that calls the deleteUserFunc I receive the error:

"null is not an object (evaluating '(0, _auth.default)().currentUser.uid')"

(UID has a valid id on page load)

const [_, setUser] = useContext(UserContext);
const uid = auth().currentUser.uid;   

const deleteUserFunc = async () => {
        await deleteAccount();
    }

    async function deleteAccount() {
        auth().currentUser.delete().then(() => {
            db.collection('users')
                .doc(user.uid)
                .delete()
        }).catch((error) => {
            console.log(error, "error")
        }).finally(() => setUser((state) => ({ ...state, isLoggedIn: false })))
    }

How can I delete from the Firestore for this user, as well as improve the code that I have written.

Any help is appreciated - thank you for your time!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

My guess is that you set your user variable to point to auth.currentUser, which becomes null when you delete the current user. So you'll need to either reverse the operations (first delete the document, then the user), or you can capture the UID in a local variable before deleting the user.

The latter would look like:

async function deleteAccount() {
    const uid = auth().currentUser.uid; // 👈
    auth().currentUser.delete().then(() => {
        db.collection('users')
            .doc(uid) // 👈
            .delete()
    }).catch((error) => {
        console.log(error, "error")
    }).finally(() => setUser((state) => ({ ...state, isLoggedIn: false })))
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda