Skip to content

Commit

Permalink
fix: correctly import sanitize-html
Browse files Browse the repository at this point in the history
  • Loading branch information
nileshgulia1 committed Jul 11, 2024
1 parent b26760c commit ecedec6
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/Utils/FormattedValue.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@ const FormattedValue = ({
const [sanitizeHtmlModule, setSanitizeHtmlModule] = useState(null);

useEffect(() => {
const loadModule = async () => {
const module = await import('sanitize-html');
setSanitizeHtmlModule(module);
};
loadModule();
import('sanitize-html').then((module) => {
setSanitizeHtmlModule(module.default);
});
}, []);

const originalValue = value;
Expand Down Expand Up @@ -77,11 +75,13 @@ const FormattedValue = ({
const html =
isLink && isObject(link) && link.title
? link.title
: sanitizeHtmlModule(value, {
allowedAttributes: {
span: ['id'],
},
}) || '';
: (sanitizeHtmlModule &&
sanitizeHtmlModule(value, {
allowedAttributes: {
span: ['id'],
},
})) ||
'';

return wrapped ? (
<Link {...linkProps}>
Expand Down

0 comments on commit ecedec6

Please sign in to comment.