Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

279
Views
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 answers
Answer question

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 Report

0

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

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!