Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

313
Visualizações
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.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

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

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda