Skip to content

Latest commit

 

History

History
27 lines (20 loc) · 426 Bytes

README.md

File metadata and controls

27 lines (20 loc) · 426 Bytes

useMermaid

A React hook for using Mermaid

usage

import React from 'react'
import { useMermaid } from './useMermaid'

const ExampleMermaid = () => {
  const graph = `
  graph TD;
      A-->B;
      A-->C;
      B-->D;
      C-->D;
  `
  const svg = useMermaid('exampleID', graph)

  if (!svg) return <div>Loading...</div>

  return <div dangerouslySetInnerHTML={{ __html: svg }} />
}

Screenshot