Package Exports
- react-sanitized-html
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-sanitized-html) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
react-sanitized-html
A React component that will sanitize user-inputted HTML code, using the popular sanitize-html
package.
Install
This React component requires both react
and sanitize-html
to be installed to work. We marked both as peer dependency so you could use the version of React as it fit.
Run npm install react-sanitized-html sanitize-html --save
to install this package.
Example usage
import SanitizedHTML from 'react-sanitized-html';
const HTML_FROM_USER = '<a href="http://bing.com/">Bing</a>';
ReactDOM.render(
<SanitizedHTML html={ HTML_FROM_USER } />,
document.getElementById('reactRoot')
);
It will output as:
<div>
<a href="http://bing.com/">Bing</a>
</div>
Options
You can add sanitize-html
options as props. For example,
<SanitizedHTML
allowedAttributes={{ 'a': ['href'] }}
allowedTags={['a']}
html={ `<a href="http://bing.com/">Bing</a>` }
/>
You can find more options here.
Contribution
Like us? Star us.
Found an issue? File us an issue.