diff options
author | 2019-04-03 01:05:21 +0300 | |
---|---|---|
committer | 2023-01-13 10:37:54 +0300 | |
commit | ef8c38749216ba8eb5918e398d12f3e48663f56f (patch) | |
tree | 870fde4959acb74700218b9697a727791cd5fb0f /vnext/src/components/UserInfo.js | |
parent | ec77d4c2416f0cb8218c7719bf46a98066603407 (diff) |
react-hooks/exhaustive-deps
Diffstat (limited to 'vnext/src/components/UserInfo.js')
-rw-r--r-- | vnext/src/components/UserInfo.js | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/vnext/src/components/UserInfo.js b/vnext/src/components/UserInfo.js index 0012d2a8..19b2f82b 100644 --- a/vnext/src/components/UserInfo.js +++ b/vnext/src/components/UserInfo.js @@ -16,18 +16,19 @@ let isMounted; export default function UserInfo(props) { const [user, setUser] = useState({ uname: props.user, uid: 0 }); + const { onUpdate } = props; useEffect(() => { isMounted = true; info(user.uname).then(response => { if (isMounted) { setUser(response.data); - props.onUpdate && props.onUpdate(response.data); + onUpdate && onUpdate(response.data); } }); return () => { isMounted = false; }; - }, []); + }, [onUpdate, user.uname]); return ( <> <div className="userinfo"> @@ -80,7 +81,7 @@ export function UserLink(props) { isMounted = false; }; } - }, [props.user]); + }, [props.user, user.uid, user.uri]); return ( user.uid ? <Link key={user.uid} to={`/${user.uname}/`} className="info-avatar"><img src={user.avatar}/>{user.uname}</Link> |