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

Do not request when an empty string is entered

Shun Miyazawa 3 лет назад
Родитель
Сommit
bd2341480b
1 измененных файлов с 1 добавлено и 1 удалено
  1. 1 1
      packages/app/src/stores/user.tsx

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

@@ -38,7 +38,7 @@ type usernameResult = {
 
 export const useSWRxUsernames = (q: string, offset?: number, limit?: number, options?: usernameRequestOptions): SWRResponse<usernameResult, Error> => {
   return useSWRImmutable(
-    q != null ? ['/users/usernames', q, offset, limit, options] : null,
+    (q != null && q.trim() !== '') ? ['/users/usernames', q, offset, limit, options] : null,
     (endpoint, q, offset, limit, options) => apiv3Get(endpoint, {
       q, offset, limit, options,
     }).then(result => result.data),