Bibliotheken wie HTML-React-Parser
$ npm install html-react-parser --save
Vast Vicuña
$ npm install html-react-parser --save
import React from 'react';
import ReactHtmlParser, { processNodes, convertNodeToElement, htmlparser2 } from 'react-html-parser';
class HtmlComponent extends React.Component {
render() {
const html = '<div>Example HTML string</div>';
return <div>{ ReactHtmlParser(html) }</div>;
}
}
yarn add html-react-parser
import React from 'react';function transform(node) { if (node.type === 'tag' && node.name === 'b') { return <div>This was a bold tag</div>; }}