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

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

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