Explorar el Código

data 浅拷贝

visuddhinanda hace 2 años
padre
commit
210f3fa4ca
Se han modificado 1 ficheros con 1 adiciones y 1 borrados
  1. 1 1
      dashboard/src/components/comment/CommentListCard.tsx

+ 1 - 1
dashboard/src/components/comment/CommentListCard.tsx

@@ -30,7 +30,7 @@ const Widget = ({
   const [data, setData] = useState<IComment[]>([]);
   useEffect(() => {
     console.log("changedAnswerCount", changedAnswerCount);
-    const newData = data.map((item) => {
+    const newData = [...data].map((item) => {
       const newItem = item;
       if (newItem.id && changedAnswerCount?.id === newItem.id) {
         newItem.childrenCount = changedAnswerCount.count;