Features
-
+
diff --git a/src/HtmlPreviewer.tsx b/src/HtmlPreviewer.tsx
index 45ac4d9..39f726d 100644
--- a/src/HtmlPreviewer.tsx
+++ b/src/HtmlPreviewer.tsx
@@ -27,6 +27,7 @@ export function HtmlPreviewer(props: PreviewerProps) {
const ref = useRef(null);
const [html, setHtml] = useState(content);
+ useEffect(() => setHtml(content), [content]);
useEffect(() => {
applyPlugins(resolvedPlugins, "transformHtml", html, setHtml);
diff --git a/src/MarkdownPreviewer.tsx b/src/MarkdownPreviewer.tsx
index 2411c55..315896f 100644
--- a/src/MarkdownPreviewer.tsx
+++ b/src/MarkdownPreviewer.tsx
@@ -1,4 +1,5 @@
import { marked, Renderer } from "marked";
+import { useEffect, useState } from "react";
import { HtmlPreviewer } from "./HtmlPreviewer";
import { highLightPlugin } from "./plugins";
@@ -24,7 +25,8 @@ export function MarkdownPreviewer(props: PreviewerProps) {
applyPlugins(resolvePlugins, "markedOptions", markedOptions);
- const html = marked.parse(content, markedOptions);
+ const [html, setHtml] = useState("");
+ useEffect(() => setHtml(marked.parse(content, markedOptions)), [content]);
return (