This is my JSON Data
const Paper = [{ Head: "<strong>Heading Content</strong>sub-heading", content: ["sample texts...."] }];
And i try to print this data to my page it working but it show like <strong>Heading Content- </strong>subheading
{Paper.map((Paper) => (
<div className='news-papper'>
{Head}
</div>
))}
I wand " Heading Content- subheading " How to print data like this?
CodePudding user response:
You need to specify the property Head
of Paper
object, and don't forget to name the array Papers
with (s) at the end, since it'is an array contains many Paper
.
{Papers.map((Paper) => (
<div className='news-papper' dangerouslySetInnerHTML={{__html: Paper.Head}}/>
))}
PS:
Papers
's not in format JSON, instead it is an array of object in JS.