I have a JSON file with a variable called htmlContent. I am trying to display this in a component but when it is rendered it shows it as text. I just want the text to be surrounded by an h2 tag.
MY JSON FILE
const BookData = {
data: [
{
id:"1",
pageHeader:"Contents",
htmlContent:`<h2>hello</h2>`,
definePrototypes:"",
exportComponent:"export default App;"
}
]
};
MY REACT COMPONENT
<section id='content'>
{props.htmlContent }
</section>
MY ACTUAL RESULT
<h2>hello</h2>
MY EXPECTED RESULT hello
<section id='content'><h2>{props.htmlContent }</h2></section>? Why is the <h2> inside the string and not the JSX unless you want to render the string <h2> and not an <h2> element.