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

165
Vistas
Objects are not valid as a React child (found: object with keys {seconds, nanoseconds}). (Firebase, React, Material Table)

I am attempting to store Firebase documents as an array of objects, set a component's state equal to that array, and then display the objects through a Material Table however am receiving the following error: "Objects are not valid as a React child (found: object with keys {seconds, nanoseconds}). If you meant to render a collection of children, use an array instead."

const getSamples = async (isAdmin, userID) => {
  initializeApp({
    apiKey: 'AIzaSyC64KY9UehoX2fk7Ugw2XNPvG4zZ7sSdsQ',
    authDomain: 'uno-genomics.firebaseapp.com',
    databaseURL: 'https://uno-genomics-default-rtdb.firebaseio.com',
    projectId: 'uno-genomics',
    storageBucket: 'uno-genomics.appspot.com',
    messagingSenderId: '351603848354',
    appId: '1:351603848354:web:e974a024da6b7e7472d3fb'
  });
  const db = getFirestore();

  const samples = [];
  if (isAdmin === true) {
    const querySnapshot = await getDocs(collection(db, 'samples'));
    querySnapshot.forEach((doc) => {
      const sample = {
        clientID: doc.get('clientID'),
        name: doc.get('name'),
        stage: doc.get('stage'),
        submissionDate: doc.get('submissionDate'),
        estimateCompletionDate: doc.get('estimateCompletionDate')
      };
      samples.push(sample);
    });
  } else {
    const querySnapshot = await getDocs(collection(db, 'samples'), where('clientID', '==', userID));
    querySnapshot.forEach((doc) => {
      const sample = {
        clientID: doc.get('clientID'),
        name: doc.get('name'),
        stage: doc.get('stage'),
        submissionDate: doc.get('submissionDate'),
        estimateCompletionDate: doc.get('estimateCompletionDate')
      };
      samples.push(sample);
    });
  }
  return samples;
};
const Dashboard = () => {
  const [samples, setSamples] = useState([]);

  const userID = localStorage.getItem('userID');
  if (localStorage.getItem('adminMode') === 'true') {
    getSamples(true, userID).then((values) => {
      setSamples(values);
    });
  } else {
    getSamples(false, userID).then((values) => {
      setSamples(values);
    });
  }

  return (
    <>
      <Helmet>
        <title> UNO COVID Resources Collection </title>
      </Helmet>
      <MaterialTable
        columns={[
          { title: 'Client ID', field: 'clientID' },
          { title: 'Name', field: 'name' },
          { title: 'Stage', field: 'stage' },
          { title: 'Submission Date', field: 'submissionDate' },
          { title: 'Estimated Completion Date', field: 'completionDateEstimate' }
        ]}
        data={samples}
        title="Samples"
      />
    </>
  );
};

I have been able to display an array of fake objects stored in the component's state through Material Table so the error must have something to do with the asynchronous accession of Firebase.

about 4 years ago · Juan Pablo Isaza
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