1- # html-react-parser [ ![ Build Status] ( https://travis-ci.org/remarkablemark/html-react-parser.svg?branch=master )] ( https://travis-ci.org/remarkablemark/html-react-parser ) [ ![ Coverage Status] ( https://coveralls.io/repos/github/remarkablemark/html-react-parser/badge.svg?branch=master )] ( https://coveralls.io/github/remarkablemark/html-react-parser?branch=master )
1+ # html-react-parser
2+
3+ [ ![ NPM] ( https://nodei.co/npm/html-react-parser.png )] ( https://nodei.co/npm/html-react-parser/ )
4+
5+ [ ![ NPM version] ( https://img.shields.io/npm/v/html-react-parser.svg )] ( https://www.npmjs.com/package/html-react-parser )
6+ [ ![ Build Status] ( https://travis-ci.org/remarkablemark/html-react-parser.svg?branch=master )] ( https://travis-ci.org/remarkablemark/html-react-parser )
7+ [ ![ Coverage Status] ( https://coveralls.io/repos/github/remarkablemark/html-react-parser/badge.svg?branch=master )] ( https://coveralls.io/github/remarkablemark/html-react-parser?branch=master )
8+ [ ![ Dependency status] ( https://david-dm.org/remarkablemark/html-react-parser.svg )] ( https://david-dm.org/remarkablemark/html-react-parser )
29
310An HTML to React parser.
411
@@ -15,7 +22,7 @@ var Parser = require('html-react-parser');
1522var reactElement = (
1623 Parser (' <p>Hello, world!</p>' ) // equivalent to `React.createElement('p', {}, 'Hello, world!')`
1724);
18- ReactDOM .render (reactElement, document .getElementById (' node ' ));
25+ require ( ' react-dom ' ) .render (reactElement, document .getElementById (' root ' ));
1926```
2027
2128## Installation
@@ -49,7 +56,7 @@ ReactDOM.render(
4956// nested elements
5057ReactDOM .render (
5158 Parser (' <ul><li>inside</li></ul>' ),
52- document .getElementedById (' root' )
59+ document .getElementById (' root' )
5360);
5461
5562// attributes are preserved
@@ -65,7 +72,7 @@ ReactDOM.render(
6572
6673` replace ` allows you to swap an element with your own React element.
6774
68- The output of ` domNode ` is the same as the output from [ htmlparser2.parseDOM] ( https://github.com/fb55/domhandler#example ) .
75+ The ` domNode ` object has the same schema as the output from [ htmlparser2.parseDOM] ( https://github.com/fb55/domhandler#example ) .
6976
7077``` js
7178var Parser = require (' html-react-parser' );
@@ -90,8 +97,7 @@ var reactElement = Parser(html, {
9097 }
9198});
9299
93- var ReactDOM = require (' react-dom' );
94- ReactDOM .render (reactElement, document .getElementById (' root' ));
100+ require (' react-dom' ).render (reactElement, document .getElementById (' root' ));
95101// <div><span style="font-size: 42px;">replaced!</span></div>
96102```
97103
0 commit comments