File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -120,8 +120,8 @@ Parser('<p id="replace">text</p>', {
120120});
121121```
122122
123- Here's an [example](https://repl.it/@remarkablemark/html-react-parser-replace-example) that replaces but keeps the children:
124- ```js
123+ Here's an [example](https://repl.it/@remarkablemark/html-react-parser-replace-example) of using `replace` to modify the children:
124+ ```jsx
125125// with ES6 and JSX
126126import domToReact from 'html-react-parser/lib/dom-to-react';
127127
@@ -166,6 +166,17 @@ ReactDOMServer.renderToStaticMarkup(reactElement);
166166</h1>
167167```
168168
169+ Here's an [example](https://repl.it/@remarkablemark/html-react-parser-issue-56) of using `replace` to exclude an element:
170+ ```js
171+ Parser('<p><br id="remove"></p>', {
172+ replace: ({ attribs }) => {
173+ if (attribs && attribs.id === 'remove') {
174+ return React.createElement(React.Fragment);
175+ }
176+ },
177+ });
178+ ```
179+
169180## Testing
170181
171182```sh
You can’t perform that action at this time.
0 commit comments