0

I'm currently trying to italicize one sentence in the middle of a string. It's a paragraph in a form that's created in redux. There are no html elements in this form schema. An object gets created with all the form content and then it gets passed into redux to display all the fields with the corresponding text.

I've tried to using string interpolation to implement html tags and also tried using escape codes(<i>) so far.

sectionPageTitle: "About",
sectionClass: "section-about",
sectionMeta: [
  {
    pageMeta: [
      {
        subsectionTitle: "WHO SHOULD USE THIS FORM?",
        subsectionMeta: [
          {
            paragraph:
              "There was a boy named Tom and he has blue hair. He has a sister and 2 dogs. One day Tom decided to buy a skateboard but his mom said no. Tom didn't care and bought one anyways. The next day he broke his arm."
          }
        ]
      }

I'd like to be able to ONLY italicize the sentence "Tom didn't care and bought one anyways."

Rchan
  • 23
  • 4
  • 2
    Is is possible to refactor the data to something like `paragragh: [{ sentence: "There was a boy named Tom and he has blue hair" }, { sentence: "He has a sister and 2 dogs" }] ...`? If so, you could add an additional property for "style", or a boolean for "italicized", etc. Beyond that, can you show the code that actually tried to display this? And include efforts on what you've tried. Sidenote; replace "sentence" with "span" or "em" if these are based on HTML elements. – Tim Lewis Jun 24 '19 at 18:53
  • 1
    Try this question... https://stackoverflow.com/questions/39758136/render-html-string-as-real-html-in-a-react-component – bflemi3 Jun 24 '19 at 18:55
  • How do you know which part of the sentence to italicize? Is it dynamic? – bflemi3 Jun 24 '19 at 18:56
  • Nope, it's not dynamic. – Rchan Jun 24 '19 at 19:46

0 Answers0