Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

281
Vistas
Map components are not reflecting

I'm learning React JS.Trying to map components by calling data from external JS file. There is no error or issue in the code.

This is content.jsx inside the /src/component folder.Here I'm rendering mapped components from App.jsx.

import React from 'react';

export default function Content(props) {
    <div>
        <p> {props.name} </p>
        <p> {props.rollNo} </p>
    </div>
}

This is App.jsx inside the src folder

import React from 'react';
import Content from './component/content';
import Data from './Data'

export default function App() {
    const jokeElements =  Data.map( (ele) => {
        return(
            <Content name={ele.name} rollNo={ele.rollNo} />
        );
    })
  
    return(
        <div>
            {jokeElements}
        </div>
    )
    
}

and rendering App.js to index.js which is in src folder. The data.js contains data in src folder.

Data.js file:

const Data=[
    {
        name:"Deepak",
        rollNo:"123"
    },
    {
        name:"Yash",
        rollNo:"124"
    },
    {
        name:"Raj",
        rollNo:"125"
    },{
        name:"Rohan",
        rollNo:"126"
    },
    {
        name:"Puneet",
        rollNo:"127"
    
    },
    {
        name:"Vivek",
        rollNo:"128"
    },
    {
        name:"Aman",
        rollNo:"129"
    },
    ]
    export default Data;

The issue I can output other JSX elements, but I'm not able to display mapped components. What's wrong with my code ?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Im guessing that "Content" component is the "Joke" component, if so, it has no return statement, try:

export default function Joke(props) {
  return (
    <div>
      <p> {props.name} </p>
      <p> {props.rollNo} </p>
    </div>
  );
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

You need a return statement in Joke function of content.js

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda