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

Issues running in browser with react-markdown #1

Closed
humphd opened this issue May 7, 2023 · 3 comments
Closed

Issues running in browser with react-markdown #1

humphd opened this issue May 7, 2023 · 3 comments

Comments

@humphd
Copy link

humphd commented May 7, 2023

Based on the warning in the recent release of remark-mermaidjs, I've tried migrating to rehype-mermaidjs. I'm having some issues using it as a drop-in replacement for what I had previously.

Here is what I'm doing:

import ReactMarkdown from "react-markdown";
import rehypeMermaid from "rehype-mermaidjs";
import remarkGfm from "remark-gfm";
...
    <ReactMarkdown
      children={children}
      { /* Previously I did [remarkGfm, remarkMermaid] and it worked well */}
      remarkPlugins={[remarkGfm]}
      rehypePlugins={[rehypeMermaid]}

This ends up crashing like so at runtime:

Uncaught caught Error: `runSync` finished async. Use `run` instead
    at assertDone (index.js:566:11)
    at Function.runSync (index.js:352:5)
    at ReactMarkdown (react-markdown.js:106:30)
    at renderWithHooks (react-dom.development.js:16305:18)
    at mountIndeterminateComponent (react-dom.development.js:20074:13)
    at beginWork (react-dom.development.js:21587:16)
    at HTMLUnknownElement.callCallback2 (react-dom.development.js:4164:14)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:4213:16)
    at invokeGuardedCallback (react-dom.development.js:4277:31)
    at beginWork$1 (react-dom.development.js:27451:7)

I also note that upon installation, I get this warning:

warning "rehype-mermaidjs > mermaid-isomorphic > mermaid > @khanacademy/simple-markdown@0.9.2" has incorrect peer dependency "react@16.14.0"

My goal is to be able to use a plugin to render Mermaid blocks in React Markdown. Perhaps this package isn't the best fit? Or maybe I'm missing something.

@remcohaszing
Copy link
Owner

I didn’t realize this at the moment of writing, but this is another breaking change. I’ll add this to the release notes. Both remark-mermaidjs@5 and rehype-mermaidjs are now asynchronous in the browser. There’s not much I can do about it, as mermaid.render() is now asynchronous. Unfortunately remark-markdown can’t use async plugins at the moment (remarkjs/react-markdown#680).

I recommend to stay on remark-mermaidjs@4 for now. Most of the benefits don’t affect browser usage anyway.

I also note that upon installation, I get this warning:

warning "rehype-mermaidjs > mermaid-isomorphic > mermaid > @khanacademy/simple-markdown@0.9.2" has incorrect peer dependency "react@16.14.0"

A fix for this hast just been merged (mermaid-js/mermaid#4350 (comment)). This warning will go away soon.

@remcohaszing remcohaszing closed this as not planned Won't fix, can't repro, duplicate, stale May 8, 2023
@ngnhat
Copy link

ngnhat commented Jun 28, 2023

@remcohaszing They have merged it. I hope this issue gets fixed soon.

@remcohaszing
Copy link
Owner

remarkjs/react-markdown#680 is still open.

As for the warning, that has been fixed. You may need to regenerate your lockfile.

tatumroaquin added a commit to tatumroaquin/mern-blog that referenced this issue Sep 19, 2023
- pin rehype-raw to v6.1.1 while waiting for type updates remarkjs/react-markdown#769
- pin remark-mermaidjs to v4.1.1 according to a similar issue remcohaszing/rehype-mermaid#1
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

No branches or pull requests

3 participants