Quantcast
Viewing all articles
Browse latest Browse all 3667

React RichText not showing in html format?

I've used React Quill for RichText Editor. And also saved data as html format. The Response shows in the Api like below:

"education": "<ul><li>Bachelor of Science (BSc) in Computer Science &amp; Engineering, </li><li>Master of Science (MSc) in Computer Science &amp; Engineering</li></ul><p><br></p>"

I used the following code to show in html format to view the data. But the data is showing without the list format. Only show text data.

import DOMPurify from "dompurify"; // Import DOMPurify at the beginning of your file// Function to sanitize HTML to prevent XSS attacksconst sanitizeHTML = (html) => {  return {    __html: DOMPurify.sanitize(html),  };};// JSX for rendering education with proper formatting<div  className="text-lg"  dangerouslySetInnerHTML={sanitizeHTML(jobDescription.education)} // Sanitize and render HTML/>

Expected Result:

  • Bachelor of Science (BSc) in Computer Science & Engineering,
  • Master of Science (MSc) in Computer Science & Engineering

Viewing all articles
Browse latest Browse all 3667

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>