Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Revise sample code for inline images #306

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

twfahey1
Copy link

@twfahey1 twfahey1 commented Sep 27, 2022

I was getting an error following the docs page on inline images:

Module not found: Package path ./lib/node.js is not exported from package /sites/mysite/node_modules/domhandler (see exports field in /sites/mysite/node_modules/domhandler/package.json)
  1 | import { HTMLReactParserOptions } from "html-react-parser"
> 2 | import { Element } from "domhandler/lib/node.js";
  3 | import parse from "html-react-parser"
  4 | import Image from "next/image"

Traced down the issue seeming to be that Element has moved into the html-react-parser now? This resolved it in my app... posting for consideration if this is in fact break from a recent update.

@vercel
Copy link

vercel bot commented Sep 27, 2022

@twfahey1 is attempting to deploy a commit to the Chapter Three Team on Vercel.

A member of the Team first needs to authorize it.

@twfahey1 twfahey1 changed the title Revise imports to reflect working setup Docs: Revise sample code for inline images Sep 27, 2022
@vercel
Copy link

vercel bot commented Sep 27, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
next-drupal ✅ Ready (Inspect) Visit Preview Nov 30, 2022 at 0:47AM (UTC)

@@ -22,8 +22,7 @@ yarn add html-react-parser
Update the component from [images](/docs/guides/inline-images) to handle inline links.

```tsx title=components/body.tsx
import { HTMLReactParserOptions, domToReact } from "html-react-parser" // highlight-line
import { Element } from "domhandler/lib/node"
import { HTMLReactParserOptions, domToReact, Element } from "html-react-parser" // highlight-line
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change doesn't look right.

I took a look at the domhandler NPM package and it now exports Element from its main entry point. See Line 14 of src/index.ts.

So the change should be:

import { Element } from "domhandler"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants