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

111
Views
How do i use props & map function to insert image urls for cards with logos using React?

I am working on a personal project where NFL Data is displayed by team. I am just learning React and would like to know how to use props and map image urls from an array to display multiple NFL logo cards. I have made a similar website using strictly css, html, and javascript but need to do it in react, anyways, this is what I have:

Home.js

import React from "react"
import { Link} from "react-router-dom"
import Box from '@material-ui/core/Box';

const teams = [
    {
        id: 1,
        teamName: "Kansas City Cheifs",
        urlImage: "public/chiefs_logo.jpg"
    },
    {
        id: 2,
        teamName: "Cincinatti Bengals",
        urlImage: "public/Bengals.jpg"
      
    },
    {
        id: 3,
        teamName: "Denver Broncos",
        urlImage: "public/Denver-Broncos-symbol.jpeg"
        
    },
    {
        id: 4,
        teamName: "Carolina Panthers",
        urlImage: "public/panthers.png"
       
    }
  ];




export default function Home(props) {

    return (
        <div className="Team-Box">
            const teamCards = teams.map(team => )
            <Box className="Box" key={teams.id} background-image={props.urlImage}/>
            <Box className="Box"  background-image={props.urlImage}/>
        <Link to="/Home"></Link>
        </div>
            
        
    )
}

What it looks like so far

[What I want it to look like][2]

[2]: https://i.stack.imgur.com/KK0tw.jpg, except for all 32 NFL teams

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Inside of your return you want something like this.

return (
  <div>
    {teams.map((team) => (
      <div key={team.id} className='Team-Box'>
        <Box
          className='Box'
          style={{ backgroundImage: `url(${team.imageUrl})` }}
        />
      </div>
    ))}
    <Link to='/Home'></Link>
  </div>
);

Here is an idea of what this would look like if you wanted to pass some data as props to a Card component responsible for displaying the information on each team.

import { useState } from 'react';

const initialTeams = [
  {
    id: 1,
    teamName: 'Kansas City Chiefs',
    urlImage: 'public/chiefs_logo.jpg',
  },
  {
    id: 2,
    teamName: 'Cincinatti Bengals',
    urlImage: 'public/Bengals.jpg',
  },
  {
    id: 3,
    teamName: 'Denver Broncos',
    urlImage: 'public/Denver-Broncos-symbol.jpeg',
  },
  {
    id: 4,
    teamName: 'Carolina Panthers',
    urlImage: 'public/panthers.png',
  },
];

const Card = ({ imageUrl, teamName }) => (
  <div className='team-card' style={{ backgroundImage: `url(${imageUrl})` }}>
    {teamName}
  </div>
);

const Home = () => {
  const [teams, setTeams] = useState(initialTeams);

  return (
    <div>
      {teams.map(({ id, imageUrl, teamName }) => (
        <Card key={id} imageUrl={imageUrl} teamName={teamName} />
      ))}
    </div>
  );
};

export default Home;
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!