Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

107
Visualizações
Pass nested object to component as props and then map the data

I have fetched some data:

const data = {
  type: "footer",
  company_data: {
    phone: "123456",
    email: "hello@site.com",
    page1: {
      title: "Terms & Conditions",
      url: "/terms-conditions/",
    },
    page2: {
      title: "Privacy Policy",
      url: "/privacy-policy/",
    },
  },
};

I use the component like this:

<Footer data={data} />

The component:

export default function Footer({ data }) {
  return (
    <div>
      {data.type}
    </div>
  );
}

Great! This prints the type: footer. However if I try to map with Object.entries I get an error:

Error: Objects are not valid as a React child (found: object with keys {phone, email, page1, page2}). If you meant to render a collection of children, use an array instead.

OK so I can't use an object as a React child. I have tried converting to array using Object.entries(data); however, this still returns the same error as it's keeping the objects inside the array.

Any help on how I can get a useable array or object to use in the component with keys and values intact would be greatly appreciated.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda