0

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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

that working , the data print like <strong>Heading Content- </strong>subheading , the strong tag is print in page not show the style of strong
You can use dangerouslySetInnerHTML
is it worked for you, or I will implement dangerouslySetInnerHTML for you
its working i will implement

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.