Skip to content
Advertisement

How to render the content of React Quill without the html markup?

I managed to get my Quill working, but now I wanted to display the contents from the editor without the html markup. I tried using react-render-html npm package, it was working fine before but now it is no longer maintained and gives me a error

JavaScript

also it shows up with html markup. So i tried using react-html-parser , htmr , html-to-react npm packages , it works perfectly for single elements but it is not working for multiple elements. So i tried console.log to see what i am receiving from backend which gave me this

JavaScript

Now i wanted to render this without the html markup , so i did again console.log to see whether it is getting converted properly by doing

JavaScript

and ultimately it gave me this

JavaScript

I also tried with dangerouslysetinnerhtml but it isn’t working again

Advertisement

Answer

Looking at your server response, the HTML tag is escaped. You need to escape it first before passing to HTML parser.

You can use html-entities to decode the server response. The easiest way is to replace all < and > characters.

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement