Skip to content

Converts HTML string directly into React components avoiding the need to use dangerouslySetInnerHTML

License

Notifications You must be signed in to change notification settings

jwelfare/react-html-parser

 
 

Repository files navigation

React HTML Parser

A utility for converting HTML strings into React components. Avoids the use of dangerouslySetInnerHTML and converts standard HTML elements, attributes and inline styles into their React equivalents.

Try the Live Demo

Travis branch Coveralls npm David

Install

npm install react-html-parser

Usage

import React from 'react';
import ReactHtmlParser from 'react-html-parser';

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

About

Converts HTML string directly into React components avoiding the need to use dangerouslySetInnerHTML

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%