@personio/html-sanitizer
v1.1.0
Published
A helper library used in Personio UI to sanitize HTML content. Written in TypeScript.
Downloads
785
Maintainers
Keywords
Readme
@personio/html-sanitizer
A helper library used in Personio UI to sanitize HTML content. Written in TypeScript.
Installation
Run
yarn add @personio/html-sanitizer
Usage
There are two ways to use this library:
As hook
import * as React from 'react';
import { useHTMLSanitizer } from '@personio/html-sanitizer';
type Props = {
htmlContent: string;
}
const MyComponent = ({ htmlContent }: Props) => {
const sanitized = useHTMLSanitizer({ html: htmlContent });
return (
<div
dangerouslySetInnerHTML={{
__html: sanitized,
}}
/>
);
}
As Component (using hook under the hood)
import * as React from 'react';
import { HTMLSanitizer } from '@personio/html-sanitizer';
type Props = {
htmlContent: string;
}
const MyComponent = ({ htmlContent }: Props) => {
return <HTMLSanitizer html={htmlContent} as="span" />;
}