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

306
Visualizações
how to map() in JSX ? ERROR: Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null

Console.log shows objects that I think can be displayed with map (). However, there is an error "Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." error pic

Where is the problem and how can I map() objects? Thanks! I export contacts.js in App.jsx:

export const contacts = [
  {
    name: "Beyonce",
    imgURL:
      "https://blackhistorywall.files.wordpress.com/2010/02/picture-device-independent-bitmap-119.jpg",
    phone: "+123 456 789",
    email: "b@beyonce.com"
  },
  {
    name: "Jack Bauer",
    imgURL:
      "https://pbs.twimg.com/profile_images/625247595825246208/X3XLea04_400x400.jpg",
    phone: "+987 654 321",
    email: "jack@nowhere.com"
  },
  {
    name: "Chuck Norris",
    imgURL:
      "https://i.pinimg.com/originals/e3/94/47/e39447de921955826b1e498ccf9a39af.png",
    phone: "+918 372 574",
    email: "gmail@chucknorris.com"
  }
];

App.jsx look like:

import React from "react";
import { Card } from "./Card";
import { contacts } from "../contacts";

function App() {
  contacts.map((item) => {
    return <Card name={item.name} img={item.imgURL} phone={item.phone} email={item.email} />
  }
  )
}

export default App;

And Card component:

import React from "react";

export const Card = (props) => {
    return (
        <div>
            <h1 className="heading">My Contacts</h1>
            <div className="card">
                <div className="top">
                    <h2 className="name">{props.name}</h2>
                    <img className="circle-img"
                        src={props.img}
                        alt="avatar_img"
                    />
                </div>
                <div className="bottom">
                    <p className="info">{props.phone}</p>
                    <p className="info">{props.email}</p>
                </div>
            </div>
        </div>
    );
}
about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

Add a return statement in the App component:

function App() {
  return contacts.map((item) => {
    return <Card name={item.name} img={item.imgURL} phone={item.phone} email={item.email} />
  }
  )
}

Notice the return before contacts.map

about 4 years ago · Juan Pablo Isaza Relatório

0

I think the problem is that you have not return any component in your App(). try this:

function App() {
  return contacts.map((item) => {
    return <Card name={item.name} img={item.imgURL} phone={item.phone} email={item.email} />
  }
  )
}
about 4 years ago · Juan Pablo Isaza Relatório

0

Updated Code

App.jsx

import React from "react";
import { Card } from "./Card";
import { contacts } from "../contacts";

function App() {

const arrayMap = contacts.map((item) => {
    return <Card 
            name={item.name} 
            img={item.imgURL} 
            phone={item.phone} 
            email={item.email} 
           />
  })
return (
      //Load arrayMap here..
    { arrayMap }
);

}
export default App;
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