diff options
author | Vitaly Takmazov | 2019-10-30 10:21:14 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-01-13 10:37:55 +0300 |
commit | 155701e27ca417b61207f2359b2519d018f0a49d (patch) | |
tree | b7234a92797069f7759bc5cd14d22f12130054de | |
parent | 522a1cdbaf0f478fb23a9f770b9caf732ea13803 (diff) |
Fix UserInfo
-rw-r--r-- | vnext/src/ui/UserInfo.js | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/vnext/src/ui/UserInfo.js b/vnext/src/ui/UserInfo.js index 29bf426f..fe9cee19 100644 --- a/vnext/src/ui/UserInfo.js +++ b/vnext/src/ui/UserInfo.js @@ -16,12 +16,10 @@ let isMounted; * @param {{user: string, onUpdate?: function, children?: Element}} props */ export default function UserInfo(props) { - /** @type {import('../api').User} user */ - const currentUser = { + const [user, setUser] = useState({ uname: props.user, uid: 0 - }; - const [user, setUser] = useState(currentUser); + }); const { onUpdate } = props; const userRef = useRef(user); useEffect(() => { @@ -37,7 +35,7 @@ export default function UserInfo(props) { return () => { isMounted = false; }; - }, [onUpdate]); + }, [onUpdate, props.user]); return ( <> <div className="userinfo"> @@ -113,7 +111,7 @@ export function UserLink(props) { return () => { isMounted = false; }; - }, []); + }, [props.user]); return ( user.uid ? <Link key={user.uid} to={`/${user.uname}/`} className="info-avatar"><img src={user.avatar} />{user.uname}</Link> |