Преглед на файлове

fix: infinite loop when artists response is undefined

Fela Maslen преди 5 години
родител
ревизия
6645efa680
променени са 1 файла, в които са добавени 3 реда и са изтрити 1 реда
  1. 3 1
      gmus-web/src/hooks/fetch/artists.ts

+ 3 - 1
gmus-web/src/hooks/fetch/artists.ts

@@ -9,6 +9,8 @@ type ArtistsResponse = {
   artists: string[];
   artists: string[];
 };
 };
 
 
+const emptyArtists: string[] = [];
+
 export function useArtists(): ArtistsResponse & {
 export function useArtists(): ArtistsResponse & {
   fetching: boolean;
   fetching: boolean;
 } {
 } {
@@ -24,7 +26,7 @@ export function useArtists(): ArtistsResponse & {
 
 
   useEffect(onFetch, [onFetch]);
   useEffect(onFetch, [onFetch]);
 
 
-  return { artists: response?.artists ?? [], fetching };
+  return { artists: response?.artists ?? emptyArtists, fetching };
 }
 }
 
 
 type ArtistDependencyResponse<K extends string, T> = { artist: string } & { [key in K]: T[] };
 type ArtistDependencyResponse<K extends string, T> = { artist: string } & { [key in K]: T[] };