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

262
Vistas
Error -::Type 'string | Element' is not assignable to type 'string'.?

I am using dangerouslySetInnerHTML in my React application (TypeScript based).

I am using it like this:

 <div dangerouslySetInnerHTML={{ __html:  faq.answer  }}/>

I am getting this error:

Type 'string | Element' is not assignable to type 'string'.

enter image description here

is there any way to fix this?

I am getting HTML from server like this <p>hello</p>. My output is correct. But while creating build my build breaks because we are doing typechecking before build.

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

0

You haven't provided much detail, but, assuming you want to serialize faq.answer in the case that it's an element, you can use Element.outerHTML like this:

<div dangerouslySetInnerHTML={{ __html: typeof faq.answer === 'string'
  ? faq.answer
  : faq.answer.outerHTML }}/>
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