From 359ec6a68ea92b3d1eecf020742157eb3be90b9f Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Sun, 9 Aug 2020 21:17:33 +0300
Subject: feat: add useFeed hook

---
 src/hooks/APIClient.ts | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

(limited to 'src/hooks')

diff --git a/src/hooks/APIClient.ts b/src/hooks/APIClient.ts
index fa23a21..ce11134 100644
--- a/src/hooks/APIClient.ts
+++ b/src/hooks/APIClient.ts
@@ -4,6 +4,10 @@ import { get } from '../requests';
 
 const fetcher = (endpoint: string) => get(endpoint).then(response => response.data);
 
+const arrayOptions = {
+  initialData: [],
+  revalidateOnMount: true
+};
 
 export const useUser = (username: string) => {
   return useSWR(
@@ -13,5 +17,9 @@ export const useUser = (username: string) => {
 };
 
 export const useProfile = (id: string) => {
-  return useSWR(id && `/profiles/${id}`, fetcher, { initialData: [] });
+  return useSWR(id && `/profiles/${id}`, fetcher, arrayOptions);
+};
+
+export const useFeed = () => {
+  return useSWR(`/feed`, fetcher, arrayOptions);
 };
-- 
cgit v1.2.3