Browse Source

把fetchData放useEffect里面

visuddhinanda 3 years ago
parent
commit
176702ec86
1 changed files with 1 additions and 5 deletions
  1. 1 5
      dashboard/src/components/article/AnthologStudioList.tsx

+ 1 - 5
dashboard/src/components/article/AnthologStudioList.tsx

@@ -20,10 +20,6 @@ const Widget = () => {
   const [tableData, setTableData] = useState<IAnthologyStudioData[]>([]);
   useEffect(() => {
     console.log("useEffect");
-    fetchData();
-  }, []);
-
-  function fetchData() {
     let url = `/v2/anthology?view=studio_list`;
     get<IAnthologyStudioListApiResponse>(url).then(function (json) {
       console.log("ajex", json);
@@ -35,7 +31,7 @@ const Widget = () => {
       });
       setTableData(newTree);
     });
-  }
+  }, []);
 
   return (
     <Card title="作者">