Reputation: 61
My api response is
{
"content" : "<div><p>Some random text</p></div>"
}
I am passing the html template as value in json response content. In my application then I am trying to render the content but the output is
My output : <div><p>Some random text</p></div>
Actual output should be : Some random text
Can anyone guide what I am missing out ?
Upvotes: 0
Views: 427
Reputation: 621
You can also checkout dangerouslySetInnerHTML to set innerHTML for HTML you get as string in response.
...
return (
...
<div dangerouslySetInnerHTML={{ __html: data.content }} />
...
)
...
Upvotes: 1
Reputation: 192
In order to converts raw HTML to a React DOM structure you need a library: html-to-react
Upvotes: 0