Skip to content

Commit

Permalink
maaaaybeeee
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake Donham committed Jun 24, 2022
1 parent a68e8e6 commit 6764fe0
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/blocks/mermaid-block/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,13 @@ mermaid.mermaidAPI.initialize({ startOnLoad: false });

export default function (props: FileBlockProps) {
const { content } = props;
const [rendered, setRendered] = React.useState("");
console.log("rendering mermaid block");
const ref = React.useRef<HTMLDivElement>(null);

React.useEffect(() => {
console.log("rendering mermaid", content);
mermaid.mermaidAPI.render("id", content, (rendered) => {
console.log("rendered mermaid", rendered);
setRendered(rendered);
ref.current!.innerHTML = rendered;
});
}, [content]);

return (
<div
key={content}
id="mermaid"
dangerouslySetInnerHTML={{ __html: rendered }}
/>
);
return <div ref={ref} id="mermaid" />;
}

0 comments on commit 6764fe0

Please sign in to comment.