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

110
Visualizações
map function not showing elements on screen

i have this part of code the map function did not show any element of the array, if i console.log the variable it shows me the elements but for some reasons i can't show the elements on the screen.

Code



function Solution({list}){
  const data = list
    console.log(data);
    return(
        <div>
            {
                data?.map((item) => {
            
                    return (
                        <div>
                            <p> {item.title} </p>
                        </div>
                    )
                })
            }
        </div>
    )

}

export default Solution;


const list = [
    {
       
         title: "Home"
    },
    {
      
        title: "Service",
        subItem: ["Clean", "Cook"]
    },
    {
   
        title: "Kitchen",
        subItem: ["Wash", "Dish"]
    },
];


Solution({list})

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

0

Please, just pass "list" link this.

<Solution list={list}/>

Hope will help you, Thanks)

about 4 years ago · Juan Pablo Isaza Relatório

0

Check this out

import React from 'react';

function Solution({list}){
  const data = list
    console.log(list);
    return(
        <div>
            {
                data?.map((item) => {
                    return (
                        <div key={item.id}>
                            <p> {item.title} </p>
                        </div>
                    )
                })
            }
        </div>
    )
}

export function App(props) {

const list = [
    {
        id:1,
         title: "Home"
    },
    {
        id:2,
        title: "Service",
        subItem: ["Clean", "Cook"]
    },
    {
        id:3,
        title: "Kitchen",
        subItem: ["Wash", "Dish"]
    },
];

  return (
    <div className='App'>
      <Solution list={list} />
    </div>
  );
}

// Log to console
console.log('Hello console')

Have a unique key prop for each element when you map an array and send list array as props to your Solution component

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