From 2812569d3964a9493ee7716e952e4aa59a8b21b2 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 12 Apr 2019 00:13:43 +0300 Subject: Make Avatar pure component --- vnext/src/components/UserInfo.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'vnext/src/components/UserInfo.js') diff --git a/vnext/src/components/UserInfo.js b/vnext/src/components/UserInfo.js index c8565cbf..7d84488e 100644 --- a/vnext/src/components/UserInfo.js +++ b/vnext/src/components/UserInfo.js @@ -19,16 +19,18 @@ export default function UserInfo(props) { const { onUpdate } = props; useEffect(() => { isMounted = true; - info(user.uname).then(response => { - if (isMounted) { - setUser(response.data); - onUpdate && onUpdate(response.data); - } - }); + if (!user.avatar) { + info(user.uname).then(response => { + if (isMounted) { + setUser(response.data); + onUpdate && onUpdate(response.data); + } + }); + } return () => { isMounted = false; }; - }, [onUpdate, user.uname]); + }, [onUpdate, user, user.avatar]); return ( <>