diff --git a/README.md b/README.md index b0534a9..56c957d 100644 --- a/README.md +++ b/README.md @@ -43,16 +43,16 @@ React tree with one single parent. ### Simple -The following example parses each node and its attributes and returns a tree of React components. +The following example parses each node and its attributes and returns a tree of React elements. ```javascript -var React = require('react'); +var ReactDOMServer = require('react-dom/server'); var HtmlToReactParser = require('html-to-react').Parser; var htmlInput = '

Title

A paragraph

'; var htmlToReactParser = new HtmlToReactParser(); -var reactComponent = htmlToReactParser.parse(htmlInput); -var reactHtml = React.renderToStaticMarkup(reactComponent); +var reactElement = htmlToReactParser.parse(htmlInput); +var reactHtml = ReactDOMServer.renderToStaticMarkup(reactElement); assert.equal(reactHtml, htmlInput); // true ``` @@ -63,7 +63,7 @@ If certain DOM nodes require specific processing, for example if you want to cap `

` tag, the following example demonstrates this: ```javascript -var React = require('react'); +var ReactDOMServer = require('react-dom/server'); var HtmlToReactParser = require('html-to-react').Parser; var htmlInput = '

Title

Paragraph

Another title

'; @@ -94,7 +94,7 @@ var processingInstructions = [ var htmlToReactParser = new HtmlToReactParser(); var reactComponent = htmlToReactParser.parseWithInstructions(htmlInput, isValidNode, processingInstructions); -var reactHtml = React.renderToStaticMarkup(reactComponent); +var reactHtml = ReactDOMServer.renderToStaticMarkup(reactComponent); assert.equal(reactHtml, htmlExpected); ``` diff --git a/lib/parser.js b/lib/parser.js index 35d2878..756a9bd 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -23,9 +23,9 @@ function Html2ReactParser(options) { }, processingInstructions); if (processingInstruction != null) { var children = reject(function (x) {return x == null || x === false;}, - addIndex(map)(function (child, i) { - return traverseDom(child, isValidNode, processingInstructions, i); - }, node.children || [])); + addIndex(map)(function (child, i) { + return traverseDom(child, isValidNode, processingInstructions, i); + }, node.children || [])); if (processingInstruction.replaceChildren) { return utils.createElement(node, index, node.data, [