فهرست منبع

add shouldFetch

Shun Miyazawa 4 سال پیش
والد
کامیت
4bf83be578
1فایلهای تغییر یافته به همراه2 افزوده شده و 1 حذف شده
  1. 2 1
      packages/app/src/stores/user-group.tsx

+ 2 - 1
packages/app/src/stores/user-group.tsx

@@ -23,8 +23,9 @@ export const useSWRxUserGroupList = (initialData?: IUserGroupHasId[]): SWRRespon
 export const useSWRxChildUserGroupList = (
     parentIds: string[] | undefined, includeGrandChildren?: boolean, initialData?: IUserGroupHasId[],
 ): SWRResponse<IUserGroupHasId[], Error> => {
+  const shouldFetch = parentIds != null && parentIds.join() !== '';
   return useSWRImmutable<IUserGroupHasId[], Error>(
-    parentIds != null ? ['/user-groups/children', parentIds.join(), includeGrandChildren] : null,
+    shouldFetch ? ['/user-groups/children', parentIds.join(), includeGrandChildren] : null,
     (endpoint, parentIds, includeGrandChildren) => apiv3Get<ChildUserGroupListResult>(
       endpoint, { parentIds, includeGrandChildren },
     ).then(result => result.data.childUserGroups),