import React from 'react'; import { Poll } from 'which-types'; import { WindowScroller, AutoSizer, List } from 'react-virtualized'; import CircularProgress from '@material-ui/core/CircularProgress'; import { makeStyles } from '@material-ui/core'; import PollCard from '../PollCard/PollCard'; interface PropTypes { polls: Poll[]; } interface RenderPropTypes { index: number; key: string; style: React.CSSProperties; } const useStyles = makeStyles(theme => ({ loader: { width: '100%', textAlign: 'center', marginTop: theme.spacing(10) } })); const Feed: React.FC = ({ polls }) => { const classes = useStyles(); const RenderItem: React.FC = ({ index, style, key }) => { const poll = polls[index]; return (
); }; const loader = (
); const list = ( {({ height, isScrolling, registerChild, onChildScroll, scrollTop }) => ( {({ width }) => (
)}
)}
); return polls.length ? list : loader; }; export default Feed;