michael-s-molina commented on code in PR #29279:
URL: https://github.com/apache/superset/pull/29279#discussion_r1644288503


##########
superset-frontend/src/hooks/apiResources/catalogs.ts:
##########
@@ -88,6 +87,10 @@ export function useCatalogs(options: Params) {
     onError?.();
   });
 
+  const resolver = useEffectEvent(() =>

Review Comment:
   There's a lot of duplicated code. Maybe something like this?
   
   ```
   export function useCatalogs(options: Params) {
     const { dbId, onSuccess, onError } = options || {};
     const [trigger] = useLazyCatalogsQuery();
     const result = useCatalogsQuery(
       { dbId, forceRefresh: false },
       {
         skip: !dbId,
       },
     );
   
     const fetchData = useCallback(
       (forceRefresh: boolean) => {
         trigger({ dbId, forceRefresh }).then(({ isSuccess, isError, data }) => 
{
           if (isSuccess) {
             onSuccess?.(data || EMPTY_CATALOGS, forceRefresh);
           }
           if (isError) {
             onError?.();
           }
         });
       },
       [dbId, onError, onSuccess, trigger],
     );
   
     const refetch = useCallback(() => {
       if (dbId) {
         fetchData(true);
       }
     }, [dbId, fetchData]);
   
     useEffect(() => {
       if (dbId && !result.currentData) {
         fetchData(false);
       }
     }, [dbId, fetchData, result.currentData]);
   
     return {
       ...result,
       refetch,
     };
   }
   ```



##########
superset-frontend/src/hooks/apiResources/schemas.ts:
##########
@@ -92,20 +91,24 @@ export function useSchemas(options: Params) {
     onError?.();
   });
 
+  const resolver = useEffectEvent(() =>

Review Comment:
   Same as before.



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