diff options
author | ilyayudovin <ilyayudovin123@gmail.com> | 2020-09-19 01:12:34 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-10-08 22:05:52 +0300 |
commit | 3aa75f9454332342fdb76d3b8466ef52f058cf4d (patch) | |
tree | c0535f559f77566f31e9de696f3c48ead89a1d71 | |
parent | 13fc0cc8ffb61d8f184707feed1f9010798c45f1 (diff) | |
download | which-ui-3aa75f9454332342fdb76d3b8466ef52f058cf4d.tar.gz |
clear cache on polls size change
-rw-r--r-- | src/components/PollCard/PollCard.tsx | 3 | ||||
-rw-r--r-- | src/components/PollsList/PollsList.tsx | 6 | ||||
-rw-r--r-- | src/components/PollsList/RenderItem.tsx | 3 |
3 files changed, 8 insertions, 4 deletions
diff --git a/src/components/PollCard/PollCard.tsx b/src/components/PollCard/PollCard.tsx index b6fdfaa..d909b79 100644 --- a/src/components/PollCard/PollCard.tsx +++ b/src/components/PollCard/PollCard.tsx @@ -44,7 +44,8 @@ const useStyles = makeStyles(theme => ({ transitionDuration: '0.5s' }, description: { - padding: '0px 16px 10px' + padding: '0px 16px 10px', + overflowWrap: 'break-word' } })); diff --git a/src/components/PollsList/PollsList.tsx b/src/components/PollsList/PollsList.tsx index bf2079a..3eeed2b 100644 --- a/src/components/PollsList/PollsList.tsx +++ b/src/components/PollsList/PollsList.tsx @@ -1,4 +1,4 @@ -import React, { useCallback, useState, useMemo } from 'react'; +import React, {useCallback, useState, useMemo, useRef, useEffect} from 'react'; import { WindowScroller, AutoSizer, @@ -25,6 +25,10 @@ const PAGE_SIZE = 10; const PollsList: React.FC<PropTypes> = ({ polls, mutate }) => { const [displayCount, setDisplayCount] = useState<number>(PAGE_SIZE); + useEffect(()=> { + cache.clearAll(); + },[polls]); + const rowRenderer = useCallback(({ index, style, key, parent }) => ( <RenderItem polls={polls} diff --git a/src/components/PollsList/RenderItem.tsx b/src/components/PollsList/RenderItem.tsx index ce6f0c9..fcac20c 100644 --- a/src/components/PollsList/RenderItem.tsx +++ b/src/components/PollsList/RenderItem.tsx @@ -27,7 +27,6 @@ const RenderItem: React.FC<PropTypes> = React.memo(({ polls, mutate, index, style, cache, parent, _key }) => { const poll = polls[index]; - const setPoll = useCallback((newPoll: Poll) => { const newPolls = [...polls]; newPolls[index] = newPoll; @@ -44,7 +43,7 @@ const RenderItem: React.FC<PropTypes> = React.memo(({ rowIndex={index} parent={parent} > - <div key={`${_key}-${poll._id}`} style={{...style, paddingBottom: '40px' }}> + <div key={`${_key}-${poll._id}`} style={{...style, paddingBottom: '20px' }}> <PollCard poll={poll} setPoll={setPoll} /> </div> </CellMeasurer> |