Browse Source

parent 改变 setCurrParent

visuddhinanda 2 years ago
parent
commit
73139a9a03
1 changed files with 3 additions and 1 deletions
  1. 3 1
      dashboard/src/components/discussion/DiscussionCreate.tsx

+ 3 - 1
dashboard/src/components/discussion/DiscussionCreate.tsx

@@ -18,7 +18,7 @@ import {
 } from "../api/Comment";
 import { useAppSelector } from "../../hooks";
 import { currentUser as _currentUser } from "../../reducers/current-user";
-import { useRef, useState } from "react";
+import { useEffect, useRef, useState } from "react";
 import MDEditor from "@uiw/react-md-editor";
 
 export type TContentType = "text" | "markdown" | "html" | "json";
@@ -60,6 +60,8 @@ const DiscussionCreateWidget = ({
   const _currUser = useAppSelector(_currentUser);
   const [currParent, setCurrParent] = useState(parent);
 
+  useEffect(() => setCurrParent(parent), [parent]);
+
   if (typeof _currUser === "undefined") {
     return <></>;
   } else {