diff options
Diffstat (limited to 'vnext/src')
-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> |