diff options
author | eug-vs <eug-vs@keemail.me> | 2020-08-14 20:42:45 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-08-14 20:42:45 +0300 |
commit | 21e5bf9ee3dc4f284c10f7915921e1e407b65b5a (patch) | |
tree | cc4e4065a9bae7e8e9d574ee6886080855975b24 | |
parent | e4452e3e575b57031de83259bbd403faa7cdce2a (diff) | |
download | which-ui-21e5bf9ee3dc4f284c10f7915921e1e407b65b5a.tar.gz |
fix: resolve SpecialProps warning
-rw-r--r-- | src/components/PollsList/PollsList.tsx | 1 | ||||
-rw-r--r-- | src/components/PollsList/RenderItem.tsx | 9 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/components/PollsList/PollsList.tsx b/src/components/PollsList/PollsList.tsx index 62273ef..41f9966 100644 --- a/src/components/PollsList/PollsList.tsx +++ b/src/components/PollsList/PollsList.tsx @@ -16,6 +16,7 @@ const PollsList: React.FC<PropTypes> = ({ polls, mutate }) => { index={index} style={style} key={key} + _key={key} /> ), [polls, mutate]); diff --git a/src/components/PollsList/RenderItem.tsx b/src/components/PollsList/RenderItem.tsx index 900dae6..5123bca 100644 --- a/src/components/PollsList/RenderItem.tsx +++ b/src/components/PollsList/RenderItem.tsx @@ -8,11 +8,11 @@ interface PropTypes { mutate: (polls: Poll[], refetch: boolean) => void; index: number; style: React.CSSProperties; - key: string; + _key: string; // https://reactjs.org/warnings/special-props.html } const compareProps = (oldProps: PropTypes, newProps: PropTypes) => { - if (oldProps.key !== newProps.key) return false; + if (oldProps._key !== newProps._key) return false; if (oldProps.index !== newProps.index) return false; if (oldProps.polls !== newProps.polls) return false; // TODO: uncomment line below to listen to style updates @@ -21,7 +21,7 @@ const compareProps = (oldProps: PropTypes, newProps: PropTypes) => { }; const RenderItem: React.FC<PropTypes> = React.memo(({ - polls, mutate, index, style, key + polls, mutate, index, style, _key }) => { const poll = polls[index]; @@ -35,8 +35,7 @@ const RenderItem: React.FC<PropTypes> = React.memo(({ }, [mutate, index, polls]); return ( - // To re-render on list resize, add this info to key - <div key={`${key}-${poll._id}-${polls.length}`} style={style}> + <div key={_key} style={style}> <PollCard poll={poll} setPoll={setPoll} /> </div> ); |