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

119
Visualizações
How to render html element in pre / REACT

Hello I am working on a blog post creation tool and I need a engine when I write in textarea <hr/> I get a line, or when I write <img/> I get an image but it doesn't render.

The post is written in a textarea and should be displayed in a div.

How to do it?

const PostCreate = () => {
    const [postValue, changeValue] = useState('')
    const handleChangeValue = (e:any) => {
        changeValue(e.target.value)
        console.log(postValue);
    }
    return (
        <div className='postCreate'>
            Create New Post
            <textarea onChange={handleChangeValue} value={postValue}/>
            <div>
                {postValue}
            </div>
        </div>
    )
}

If I write <hr/> I get the string <hr/> instead of a line: error img

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

0

You can use dangerouslySetInnerHTML prop for the div.

<div dangerouslySetInnerHTML={{ __html: postValue }} />

You can check it on this document.

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