diff options
author | eug-vs <eug-vs@keemail.me> | 2020-06-14 20:39:16 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-06-14 20:39:16 +0300 |
commit | 61a424debfbfa98570e070fbf25d03aa9c56d679 (patch) | |
tree | 0c032edf74571350fd0f5f9251a3493a487b6008 /src/components/Feed/Feed.tsx | |
parent | c7f2999ee797ea5e3bfb29517a4f13206162cc6f (diff) | |
download | which-ui-61a424debfbfa98570e070fbf25d03aa9c56d679.tar.gz |
refactor: structurize pages
Diffstat (limited to 'src/components/Feed/Feed.tsx')
-rw-r--r-- | src/components/Feed/Feed.tsx | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/src/components/Feed/Feed.tsx b/src/components/Feed/Feed.tsx index 604c167..8dc3ec1 100644 --- a/src/components/Feed/Feed.tsx +++ b/src/components/Feed/Feed.tsx @@ -1,11 +1,10 @@ -import React, { useState, useEffect } from 'react'; +import React from 'react'; import { makeStyles } from '@material-ui/core/styles'; import { Poll } from '../../types'; import PollCard from '../PollCard/PollCard'; -import { get } from '../../requests'; interface PropTypes { - page: string; + polls: Poll[]; } const useStyles = makeStyles(theme => ({ @@ -16,20 +15,9 @@ const useStyles = makeStyles(theme => ({ } })); -const Feed: React.FC<PropTypes> = ({ page }) => { - const [polls, setPolls] = useState<Poll[]>([]); +const Feed: React.FC<PropTypes> = ({ polls }) => { const classes = useStyles(); - let endpoint = '/polls'; - // TODO: Make this work - if (page === 'feed') endpoint = '/polls'; - - useEffect(() => { - get(endpoint).then(response => { - setPolls(response.data); - }); - }, [endpoint]); - return ( <div className={classes.root}> {polls.map(poll => <PollCard poll={poll} key={poll._id} />)} |