Skip to content

v3.5.2

Choose a tag to compare

@linyows linyows released this 27 Apr 07:52
· 24 commits to main since this release
4569017

What's Changed

Bug Fixes

  • Fix Cannot read properties of undefined (reading 'getBBox') and intermittent hydration failures in mermaid code blocks on Next.js static-export sites by @linyows in #218
    • Disable mermaid's auto-render with mermaid.startOnLoad = false so the library no longer mutates the DOM (and inserts its temporary <div id=\"dmermaid-...\"> workspace) before React hydration runs
    • Switch from mermaid.run() to mermaid.render(id, source) and inject the returned SVG string via useState + dangerouslySetInnerHTML, keeping the rendered DOM under React's control
    • Capture the original diagram source once into sourceRef so re-runs (Strict Mode, HMR, language change) do not re-parse an already-replaced node
    • Skip mermaid.render when mermaidSvg is already populated, removing the race that produced duplicate d{id} workspace divs and Failed to execute 'removeChild' on 'Node' errors
    • Use distinct keys on the source vs rendered <pre> so React unmount → mount instead of reconciling differing children
    • Pin securityLevel: 'strict' explicitly in mermaid.initialize (matches mermaid v11's default but documents the XSS posture for diagram source coming from Notion)

Full Changelog: v3.5.1...v3.5.2