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

128
Vistas
How to check a set of names exist or not and display image in table using react

My requirement i have a json object list using that i am checking for a name in json and if the name exist i am displaying a image from local assets folder. my code is below

After .map im displaying data like below

 <td>
                      <div>
                        <img
                          src={
                            DynamicData.CompanyName.includes("Lenovo")
                              ? LenovoImage
                              : DynamicData.CompanyName.includes("Dell")
                              ? DellImage
                              : null
                          }
                          alt="img"
                          className="DataLogo"
                        />
                      </div>
                    </td>

So here how can i display if i have more than 2 options is this approach is good ? are there any other approach ?

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

0

If there are many values to check, this looks more convenient.

const imagesMapping = {
  Lenovo: LenoviImage,
  Dell: DellImage,
  // other values
}

const company = Object.keys(imagesMapping).find(name =>
  DynamicData.CompanyName.includes(name));

const image = company ? imagesMapping[company] : null; // instead of null better use a DefaultImage
const result = <img src={image} alt="img" className="DataLogo" />
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