Просмотр исходного кода

Merge pull request #5188 from weseek/fix/86680-fetching-child-user-group-error

fix: 86680 Fetching child user group error
Shun Miyazawa 4 лет назад
Родитель
Сommit
4e84182d69
1 измененных файлов с 3 добавлено и 2 удалено
  1. 3 2
      packages/app/src/stores/user-group.tsx

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

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