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

342
Visualizações
React JS: Getting [object object] When Concatenating Object Element With String

Im defining row content in React Table, when type the element variable alone it will print correctly, but when I try to concatenate it with other variable I get [Object Object] instead

the Object:

// Icons object
const typeIcons = {
  DINEIN:  <FlatwareIcon color="secondary" />  ,
  DELIVERY: <DeliveryDiningIcon color="secondary" />,
  TAKEAWAY: <RoomServiceIcon  color="success"/>
}

When using object element with type 'DINEIN' for example, it works perfectly :

row2: typeIcons[item.order_type],

and gives the required icon, But when concatenating with other variable, i.e.

row2: typeIcons[item.order_type] + item.order_type, 

the outcome will be: [Object Object]DINEIN Any explanation ? Thanks in advance for your kind help.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

typeIcons[item.order_type] is object(React component) while item.order_type is a string. You cannot concatenate string with object. I assume value under row2 must contain a React component, then you can try something like this:

row2: <>{typeIcons[item.order_type]} {item.order_type}</>, 
about 4 years ago · Juan Pablo Isaza Relatório
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