Skip to content

Commit 8b75b57

Browse files
Create main module that converts HTML to React
- The module will take an HTML string and return a React element or an array of React elements - It uses `htmlToDOM` and `domToReact` helpers - Update `package.json` with the main entry point
1 parent bae093b commit 8b75b57

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

index.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict';
2+
3+
/**
4+
* Module dependencies.
5+
*/
6+
var htmlToDOM = require('./lib/html-to-dom');
7+
var domToReact = require('./lib/dom-to-react');
8+
9+
/**
10+
* Convert HTML to React.
11+
*
12+
* @param {String} html - The HTML.
13+
* @return {ReactElement|Array}
14+
*/
15+
function htmlToReact(html) {
16+
return domToReact(htmlToDOM(html));
17+
}
18+
19+
/**
20+
* Export HTML to React parser.
21+
*/
22+
module.exports = htmlToReact;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.0.1",
44
"description": "Convert HTML string to React elements.",
55
"author": "Mark <mark@remarkablemark.org>",
6+
"main": "index.js",
67
"scripts": {
78
"test": "mocha"
89
},

0 commit comments

Comments
 (0)