You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
494 B
TypeScript
24 lines
494 B
TypeScript
import DOMPurify from 'dompurify';
|
|
import React from 'react';
|
|
|
|
type ReceivedProps = {
|
|
html: string;
|
|
tag?: React.ElementType;
|
|
key?: any;
|
|
className?: string;
|
|
};
|
|
|
|
export const SessionHtmlRenderer = ({ tag = 'div', key, html, className }: ReceivedProps) => {
|
|
const clean = DOMPurify.sanitize(html, {
|
|
USE_PROFILES: { html: true },
|
|
FORBID_ATTR: ['script'],
|
|
});
|
|
|
|
return React.createElement(tag, {
|
|
key,
|
|
className,
|
|
|
|
dangerouslySetInnerHTML: { __html: clean },
|
|
});
|
|
};
|