uiwjs / react-markdown-preview

React component preview markdown text in web browser. The minimal amount of CSS to replicate the GitHub Markdown style. Support dark-mode/night mode.
https://uiwjs.github.io/react-markdown-preview
MIT License
277 stars 49 forks source link

visit is not a function #197

Closed wjureczka closed 2 years ago

wjureczka commented 2 years ago

Hey everyone! I have a problem with rendering the preview component. I do everything like it is in the demo, but still got an error:

Uncaught TypeError: (0 , unist_util_visit__WEBPACK_IMPORTED_MODULE_1__.visit) is not a function at reservedMeta.js:9:1 at wrapped (index.js:115:1) at next (index.js:65:1) at done (index.js:148:1) at then (index.js:158:1) at wrapped (index.js:136:1) at next (index.js:65:1) at Object.run (index.js:36:1) at executor (index.js:321:1) at Function.run (index.js:312:1) react-dom.development.js:20085 The above error occurred in the component

Could anynone help?

jaywcjlove commented 2 years ago

@wjureczka Can you reproduce this error example for me with codesandbox.io ?

dacevedo12 commented 2 years ago

Same issue here

TypeError: (0 , _unistUtilVisit.visit) is not a function
      at apply (node_modules/@uiw/react-markdown-preview/src/plugins/reservedMeta.ts:9:5)
      at wrapped (node_modules/react-markdown/node_modules/trough/index.js:115:27)
      at next (node_modules/react-markdown/node_modules/trough/index.js:65:9)
      at done (node_modules/react-markdown/node_modules/trough/index.js:148:15)
      at then (node_modules/react-markdown/node_modules/trough/index.js:158:5)
      at wrapped (node_modules/react-markdown/node_modules/trough/index.js:136:9)
      at next (node_modules/react-markdown/node_modules/trough/index.js:65:9)
      at Object.run (node_modules/react-markdown/node_modules/trough/index.js:36:9)
      at executor (node_modules/react-markdown/node_modules/unified/lib/index.js:321:20)
      at Function.run (node_modules/react-markdown/node_modules/unified/lib/index.js:312:5)
      at Function.runSync (node_modules/react-markdown/node_modules/unified/lib/index.js:350:15)
      at ReactMarkdown (node_modules/react-markdown/lib/react-markdown.js:107:30)
dacevedo12 commented 2 years ago

I don't see unist-util-visit anywhere in the package.json of this repo. That may have something to do.

https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-extraneous-dependencies.md

Should reopen

jaywcjlove commented 2 years ago

@dacevedo12 I know the reason for the error. thx!

 npm ls unist-util-visit

├─┬ react-markdown@8.0.3
│ ├─┬ remark-rehype@10.1.0
│ │ └─┬ mdast-util-to-hast@12.1.2
│ │   ├─┬ mdast-util-definitions@5.1.1
│ │   │ └── unist-util-visit@4.1.0 deduped
│ │   └── unist-util-visit@4.1.0 deduped
│ └── unist-util-visit@4.1.0 deduped
├─┬ rehype-attr@2.0.8
│ └── unist-util-visit@4.1.0 deduped
├─┬ rehype-autolink-headings@6.1.1
│ └── unist-util-visit@4.1.0 deduped
├─┬ rehype-ignore@1.0.1
│ ├─┬ hast-util-select@5.0.2
│ │ └── unist-util-visit@4.1.0 deduped
│ └── unist-util-visit@4.1.0 deduped
├─┬ rehype-prism-plus@1.4.1
│ └── unist-util-visit@4.1.0 deduped
├─┬ rehype-raw@6.1.1
│ └─┬ hast-util-raw@7.2.1
│   └── unist-util-visit@4.1.0 deduped
├─┬ rehype-rewrite@3.0.6
│ └── unist-util-visit@4.1.0 deduped
├─┬ rehype-slug@5.0.1
│ └── unist-util-visit@4.1.0 deduped
├─┬ remark-gfm@3.0.1
│ └─┬ mdast-util-gfm@2.0.1
│   └─┬ mdast-util-to-markdown@1.3.0
│     └── unist-util-visit@4.1.0 deduped
└── unist-util-visit@4.1.0
jaywcjlove commented 2 years ago

@wjureczka Upgrade @uiw/react-markdown-preview@4.0.23

dacevedo12 commented 2 years ago

Whoa, that was fast! Thank you very much