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

274
Vistas
Firestore getDoc wont work when using pathSegments in react

I'm trying to do a very simple data load from firebase but it wont work when I use path segments in react

something very simple as

import { getFirestore, getDoc, getDocs, setDoc, doc, updateDoc, getCollection, collection } from "firebase/firestore";
import { firebaseConfig } from "config";

// Initialize Firebase
const app = initializeApp(firebaseConfig);
const firestore = getFirestore(app);


getDoc(doc(firestore, 'collection', ['path','to','document']));

it will throw an exception

Uncaught (in promise) TypeError: n.split is not a function

how can i do to pass an array for that function?

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

0

The doc() doesn't take an array as param but path segments (strings). Try using the spread syntax on array as shown below:

getDoc(doc(firestore, 'collection', ...['path','to','document']));
// spread syntax here                ⬆


// Equivalent to:
getDoc(doc(firestore, 'collection', 'path', 'to', 'document'));

doc() function signature from the documentation:

export declare function doc(firestore: Firestore, path: string, ...pathSegments: string[]): DocumentReference<DocumentData>;
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