Skip to content

Commit

Permalink
Error importing HtmlReactParser in index.cjs file #44
Browse files Browse the repository at this point in the history
  • Loading branch information
pmi authored and alansemenov committed Oct 3, 2024
1 parent a1a261c commit 622c63a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/RichText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type {RichTextParams} from './types'


// Converts an HTML string to one or more React elements
import HTMLReactParser from 'html-react-parser';
import * as parser from 'html-react-parser';

// Replaces "matching" domNodes
import {createReplacer} from './RichText/createReplacer';
Expand All @@ -26,7 +26,9 @@ export function RichText<RestProps = Record<string, unknown>>({
return <CustomTag className={className}>
{
data.processedHtml
? HTMLReactParser(data.processedHtml, {
/* try parser.default.default first because import is wrapped with __toesm() in cjs files
* for node compatibility, which adds default export resulting in parser.default.default */
? (parser.default['default'] || parser.default)(data.processedHtml, {
replace: createReplacer({
...rest,
// These should be last, so they can't be overridden
Expand Down

0 comments on commit 622c63a

Please sign in to comment.