From 78218c0f3427ad79de003ac59cffb99b08f0ae7d Mon Sep 17 00:00:00 2001 From: eug-vs Date: Mon, 10 Aug 2020 13:47:02 +0300 Subject: fix: resolve eslint errors --- src/containers/Profile/Profile.tsx | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/containers') diff --git a/src/containers/Profile/Profile.tsx b/src/containers/Profile/Profile.tsx index f7678de..7e929fb 100644 --- a/src/containers/Profile/Profile.tsx +++ b/src/containers/Profile/Profile.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useCallback } from 'react'; +import React, { useEffect, useMemo } from 'react'; import { useHistory, useParams } from 'react-router-dom'; import { Poll } from 'which-types'; import { Container } from '@material-ui/core'; @@ -26,15 +26,12 @@ const Profile: React.FC = () => { }, [username, history, user]); - const totalVotes = useCallback( - polls.reduce( - (total: number, current: Poll) => { - const { left, right } = current.contents; - return total + left.votes + right.votes; - }, 0 - ), - [polls] - ); + const totalVotes = useMemo(() => polls.reduce( + (total: number, current: Poll) => { + const { left, right } = current.contents; + return total + left.votes + right.votes; + }, 0 + ), [polls]); return ( @@ -46,8 +43,8 @@ const Profile: React.FC = () => { /> { isValidating && !polls - ? - : + ? + : } ); -- cgit v1.2.3