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

113
Vistas
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 Respuestas
Responde la pregunta

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 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