Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

167
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!