-3

I want to remove all html tag from API(description section) while fetching the data i go html tag. I have attached the screenshot of the output, please have a look.

enter image description here enter image description here

bob perno
  • 15
  • 8

3 Answers3

0
  1.  npm i react-html-parser
    
  2. install import parse from "html-react-parser";
    
  3. <p>{parse(description.substring(0, 299))}</p>
    
Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
bob perno
  • 15
  • 8
0

You can convert the incoming HTML from the API response to display as HTML by using this:

  <span dangerouslySetInnerHTML={{ __html: blog }} ></span>
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 17 '23 at 13:26
-1

This should work.

    blogs = blogs.replace(/<(.|\n)*?>/g, '');
    setBlog(blogs)

Replacing all tags