Convert HTML Strings Into Components – React HTML Parser

The React HTML Parser converts HTML strings directly into React components. Avoids the use of dangerouslySetInnerHTML and converts standard HTML elements, attributes and inline styles into their React equivalents.

Installation:

# Yarn
$ yarn add react-html-parser

# NPM
$ npm install react-html-parser --save

Usage:

import React from 'react';
import ReactHtmlParser, { processNodes, convertNodeToElement, htmlparser2 } from 'react-html-parser';

class HtmlComponent extends React.Component {
  render() {
    const html = '<div>HTML strings</div>';
    return <div>{ ReactHtmlParser(html) }</div>;
  }
}

Preview:

React HTML Parser

Download Details:

Author: wrakky

Live Demo: View The Demo

Download Link: Download The Source Code

Official Website: https://github.com/wrakky/react-html-parser

License: MIT

You Might Be Interested In:

Add Comment