1.0.8 • Published 2 years ago
react-html-markup v1.0.8
react-html-markup
An HTML to React parser that works on the server and the browser:
It converts an HTML string to React elements.
Example
In React JS (Hooks)
--------------------
import React from 'react';
import Markup from 'react-html-markup';
const Foo = () {
const dbString = '<p>Hello from <b>React HTML Markup</b></p>';
return (
<Markup
htmlString={ dbString } // html string that is coming from database or static html string.
htmlTag='div' // You can add any html tag
... // You can add multiple attributes here like (class, data-title, style), that will apply on htmlTag you defined (div)
/>
);
}
export default Foo;
Output show in Browser:
-----------------------
<div><p>Hello from <b>React HTML Markup</b></p></div>
Installation
NPM:
$ npm install react-html-markup --save
Yarn:
$ yarn add react-html-markup