npm.io
1.0.8 • Published 4 years ago

react-html-markup

Licence
ISC
Version
1.0.8
Deps
0
Size
37 kB
Vulns
0
Weekly
0

react-html-markup

[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

Keywords