Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

115
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!