From 917d83bfb70d863944df62fb3ca254ba74e67e6e Mon Sep 17 00:00:00 2001 From: eug-vs Date: Fri, 14 Aug 2020 04:09:56 +0300 Subject: feat: add EmptyState component --- src/hooks/APIClient.ts | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'src/hooks') diff --git a/src/hooks/APIClient.ts b/src/hooks/APIClient.ts index 9563bd6..f66ef2e 100644 --- a/src/hooks/APIClient.ts +++ b/src/hooks/APIClient.ts @@ -2,18 +2,10 @@ import useSWR, { responseInterface } from 'swr'; import { User, Poll, Feedback } from 'which-types'; import { get } from '../requests'; - -interface Response extends responseInterface { - data: T; -} +type Response = responseInterface; const fetcher = (endpoint: string) => get(endpoint).then(response => response.data); -const arrayOptions = { - initialData: [], - revalidateOnMount: true -}; - export const useUser = (username: string | null): Response => { return useSWR( username && `/users?username=${username}`, @@ -22,13 +14,13 @@ export const useUser = (username: string | null): Response => { }; export const useProfile = (id: string): Response => { - return useSWR(id && `/profiles/${id}`, fetcher, arrayOptions) as Response; + return useSWR(id && `/profiles/${id}`, fetcher) as Response; }; export const useFeed = (): Response => { - return useSWR('/feed', fetcher, { ...arrayOptions, revalidateOnFocus: false }) as Response; + return useSWR('/feed', fetcher, { revalidateOnFocus: false }) as Response; }; export const useFeedback = (): Response => { - return useSWR('/feedback', fetcher, arrayOptions) as Response; + return useSWR('/feedback', fetcher) as Response; }; -- cgit v1.2.3