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

346
Vistas
How to enter formatted template in React

I have an online letter template that I want to display ask text in my reactApp

My email is formatted with paragraphs and bold headings. How can I integrate the same formatting into React without having to use bruteforce and including a lot of tags.

I tried using a template literal to preserve the formatting but it does not work.

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

0

As Joseph stated in the comments, you can use dangerouslySetInnerHTML to render a string of HTML.

Example: code-sandbox

export default function App() {
  const htmlString = "<h1>Hello world</h1>";
  return (
    <>
      <div dangerouslySetInnerHTML={{ __html: htmlString }}></div>
    </>
  );
}

However, it's important to be aware of the security risks as the documentation states:

dangerouslySetInnerHTML is React’s replacement for using innerHTML in the browser DOM. In general, setting HTML from code is risky because it’s easy to inadvertently expose your users to a cross-site scripting (XSS) attack. So, you can set HTML directly from React, but you have to type out dangerouslySetInnerHTML and pass an object with a __html key, to remind yourself that it’s dangerous.

Source: https://reactjs.org/docs/dom-elements.html#dangerouslysetinnerhtml

over 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
Asistente virtual