fix: rename SessionHtmlRenderer as prop to tag to work with styled components

pull/3206/head
Ryan Miller 1 year ago
parent 2b4f2ba1bc
commit 12ae04b7ec

@ -42,7 +42,7 @@ export const I18n = <T extends LocalizerToken>(props: I18nProps<T>) => {
/** If the string contains a relevant formatting tag, render it as HTML */ /** If the string contains a relevant formatting tag, render it as HTML */
if (i18nString.match(formattingTagRegex)) { if (i18nString.match(formattingTagRegex)) {
return <SessionHtmlRenderer as={props.as} html={i18nString} />; return <SessionHtmlRenderer tag={props.as} html={i18nString} />;
} }
const Comp = props.as ?? React.Fragment; const Comp = props.as ?? React.Fragment;

@ -3,18 +3,18 @@ import React from 'react';
type ReceivedProps = { type ReceivedProps = {
html: string; html: string;
as?: React.ElementType; tag?: React.ElementType;
key?: any; key?: any;
className?: string; className?: string;
}; };
export const SessionHtmlRenderer = ({ as = 'div', key, html, className }: ReceivedProps) => { export const SessionHtmlRenderer = ({ tag = 'div', key, html, className }: ReceivedProps) => {
const clean = DOMPurify.sanitize(html, { const clean = DOMPurify.sanitize(html, {
USE_PROFILES: { html: true }, USE_PROFILES: { html: true },
FORBID_ATTR: ['script'], FORBID_ATTR: ['script'],
}); });
return React.createElement(as, { return React.createElement(tag, {
key, key,
className, className,

Loading…
Cancel
Save