lyndsiWilliams commented on code in PR #22043:
URL: https://github.com/apache/superset/pull/22043#discussion_r1072715610


##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/index.tsx:
##########
@@ -91,22 +90,22 @@ export default function AddDataset() {
       })
     : undefined;
 
-  const getDatasetsList = async () => {
-    await UseGetDatasetsList(queryParams)
-      .then(json => {
-        setDatasets(json?.result);
-      })
-      .catch(error =>
-        logging.error('There was an error fetching dataset', error),
-      );
-  };
+  const { getDatasetsList, datasets, datasetNames } =
+    useGetDatasetsList(queryParams);
 
   useEffect(() => {
     if (dataset?.schema) {
       getDatasetsList();
     }
   }, [dataset?.schema]);

Review Comment:
   Thank you for the explanation! Fixed in [`this 
commit`](https://github.com/apache/superset/pull/22043/commits/41fbaeb11bfd574a84a24732cadd2dae25e6f39d).



##########
superset-frontend/src/views/CRUD/data/hooks.ts:
##########
@@ -75,11 +76,36 @@ export function useQueryPreviewState<D extends 
BaseQueryObject = any>({
   };
 }
 
-export const UseGetDatasetsList = (queryParams: string | undefined) =>
-  SupersetClient.get({
-    endpoint: `/api/v1/dataset/?q=${queryParams}`,
-  })
-    .then(({ json }) => json)
-    .catch(error =>
-      logging.error('There was an error fetching dataset', error),
-    );
+export const useGetDatasetsList = (queryParams: string | undefined) => {
+  const [datasets, setDatasets] = useState<DatasetObject[]>([]);
+
+  const getDatasetsList = () =>
+    SupersetClient.get({
+      endpoint: `/api/v1/dataset/?q=${queryParams}`,
+    })
+      .then(({ json }) => {
+        setDatasets(json?.result);
+      })
+      .catch(error =>
+        logging.error('There was an error fetching dataset', error),
+      );

Review Comment:
   Fixed in [`this 
commit`](https://github.com/apache/superset/pull/22043/commits/41fbaeb11bfd574a84a24732cadd2dae25e6f39d).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to