refactor(frontend): remove unnecessary state in useApi hooks

This commit is contained in:
Julian Tölle 2020-11-15 02:34:22 +01:00
parent ca4e10e473
commit 42737e570d

View file

@ -31,8 +31,6 @@ export const useRecentListens = (options: PaginationOptions) => {
export const useListensReport = (options: ListenReportOptions) => { export const useListensReport = (options: ListenReportOptions) => {
const { client } = useApiClient(); const { client } = useApiClient();
const [initialData] = useState(INITIAL_EMPTY_ARRAY);
const fetchData = useMemo(() => () => getListensReport(options, client), [ const fetchData = useMemo(() => () => getListensReport(options, client), [
options, options,
client, client,
@ -40,7 +38,7 @@ export const useListensReport = (options: ListenReportOptions) => {
const { value: report, pending: isLoading, error } = useAsync( const { value: report, pending: isLoading, error } = useAsync(
fetchData, fetchData,
initialData INITIAL_EMPTY_ARRAY
); );
return { report, isLoading, error }; return { report, isLoading, error };
@ -49,8 +47,6 @@ export const useListensReport = (options: ListenReportOptions) => {
export const useTopArtists = (options: TopArtistsOptions) => { export const useTopArtists = (options: TopArtistsOptions) => {
const { client } = useApiClient(); const { client } = useApiClient();
const [initialData] = useState(INITIAL_EMPTY_ARRAY);
const fetchData = useMemo(() => () => getTopArtists(options, client), [ const fetchData = useMemo(() => () => getTopArtists(options, client), [
options, options,
client, client,
@ -58,7 +54,7 @@ export const useTopArtists = (options: TopArtistsOptions) => {
const { value: topArtists, pending: isLoading, error } = useAsync( const { value: topArtists, pending: isLoading, error } = useAsync(
fetchData, fetchData,
initialData INITIAL_EMPTY_ARRAY
); );
return { topArtists, isLoading, error }; return { topArtists, isLoading, error };