snippetjavascriptreactMajor
How to render HTML string as real HTML?
Viewed 0 times
htmlstringrenderrealhow
Problem
Here's what I tried and how it goes wrong.
This works:
This doesn't:
The description property is just a normal string of HTML content. However it's rendered as a string, not as HTML for some reason.
Any suggestions?
This works:
Hi there!" }} />This doesn't:
The description property is just a normal string of HTML content. However it's rendered as a string, not as HTML for some reason.
Any suggestions?
Solution
Check if the text you're trying to append to the node is not escaped like this:
Instead of this:
if is escaped you should convert it from your server-side.
The node is text because is escaped
The node is a dom node because isn't escaped
var prop = {
match: {
description: '<h1>Hi there!</h1>'
}
};Instead of this:
var prop = {
match: {
description: 'Hi there!'
}
};if is escaped you should convert it from your server-side.
The node is text because is escaped
The node is a dom node because isn't escaped
Code Snippets
var prop = {
match: {
description: '<h1>Hi there!</h1>'
}
};var prop = {
match: {
description: '<h1>Hi there!</h1>'
}
};Context
Stack Overflow Q#39758136, score: 79
Revisions (0)
No revisions yet.