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

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

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 Denunciar

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