Skip to content

Commit

Permalink
catch errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake Donham committed Jun 24, 2022
1 parent 6764fe0 commit d9dfd39
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/blocks/mermaid-block/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ export default function (props: FileBlockProps) {
const ref = React.useRef<HTMLDivElement>(null);

React.useEffect(() => {
mermaid.mermaidAPI.render("id", content, (rendered) => {
ref.current!.innerHTML = rendered;
});
try {
mermaid.mermaidAPI.render("id", content, (rendered) => {
ref.current!.innerHTML = rendered;
});
} catch (error) {
ref.current!.innerHTML = String(error);
}
}, [content]);

return <div ref={ref} id="mermaid" />;
Expand Down

0 comments on commit d9dfd39

Please sign in to comment.