From aed13f230d2673a489aec455e48d6edbb503e001 Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Mon, 29 Jun 2020 22:03:52 +0300
Subject: refactor: improve poll addition

---
 src/pages/FeedPage/FeedPage.tsx | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

(limited to 'src/pages/FeedPage/FeedPage.tsx')

diff --git a/src/pages/FeedPage/FeedPage.tsx b/src/pages/FeedPage/FeedPage.tsx
index 329647e..0017275 100644
--- a/src/pages/FeedPage/FeedPage.tsx
+++ b/src/pages/FeedPage/FeedPage.tsx
@@ -20,9 +20,15 @@ const FeedPage: React.FC<PropTypes> = ({ navigate, user }) => {
     });
   }, []);
 
+  const addPoll = (poll: Poll): void => {
+    polls.unshift(poll);
+    setPolls([...polls]);
+  };
+
+
   return (
     <>
-      {user && <PollSubmission user={user} polls={polls} setPolls={setPolls} />}
+      {user && <PollSubmission user={user} addPoll={addPoll} />}
       <Feed polls={polls} navigate={navigate} />
     </>
   );
-- 
cgit v1.2.3

