Browse Source

Merge pull request #1535 from visuddhinanda/agile

Agile#1527
visuddhinanda 2 years ago
parent
commit
674e1e84f8

+ 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 {

+ 2 - 1
dashboard/src/components/discussion/DiscussionTopicChildren.tsx

@@ -47,7 +47,8 @@ const DiscussionTopicChildrenWidget = ({
   const [items, setItems] = useState<IItem[]>();
   const [currTopic, setCurrTopic] = useState(topic);
 
-  console.log("topicId", topicId);
+  useEffect(() => setCurrTopic(topic), [topic]);
+
   useEffect(() => {
     if (loading === false) {
       const ele = document.getElementById(`answer-${focus}`);