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

194
Views
Firebase database collection rendering List

I am using Firebase database in my project. When I retrieve my data the payload looks like this:

{
   -randomId123: {name: "foo", surname: "bar" },
   ....
}

How can I correctly render my list in my component:

export const App = () => {
  const [data, setData] = useState(dummyData);

  const items = data.map((v) => {
      console.log(v.val())
  });

 setData(items)

  return (
    <div>
      <> {data.map((d) => {
              <p> {d.key} {d.name} {d.surname} </p>
  })} </>
    </div>
  );
};

Expected output:

<p> randomId123 foo bar <p>

Objects are not valid as a React child (found: object with keys {-randomId123 , -randomId456, -randomId789}). If you meant to render a collection of children, use an array instead.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The following is an object.

{
   -randomId123: {name: "foo", surname: "bar" },
   ....
}

If this were data, then one may not be able to iterate using data.map().

In order to render:

<p> randomId123 foo bar <p>

Please try below:

<div>
  {Object.keys(data).map(k => (
    <p> {k} {data[k].name} {data[k].surname} </p>
  )}
</div>
about 4 years ago · Juan Pablo Isaza Report
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!