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

159
Views
Inserting image tag inside a template literal

I'm trying to insert an image depending on a state - but this will display the string of img src=${redExclamation} .

return `${
    isEmpty
        ? `<img src=${redExclamation} />`
        : `<img src=${greenCheck} /> `
    }`;

I've tried it a different way where i got rid of the string literal:

return `${
    isEmpty
        ? <img src=${redExclamation} />
        : <img src=${greenCheck} />
    }`;

But this will show [object Object] in the HTML. Not sure what I should be doing here. Any help would be appreciated!

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

0

you are returning a string, not html.

return isEmpty
        ? <img src={redExclamation} />
        : <img src={greenCheck} />;

Might be what you need

about 4 years ago · Juan Pablo Isaza Report

0

You can try without the outer literal like the following:

return isEmpty ? `<img src=${redExclamation} />` : `<img src=${greenCheck} />`

Or if you're trying to return a jsx you should do it as per docs

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!