aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/components
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2019-02-06 23:47:04 +0300
committerGravatar Vitaly Takmazov2023-01-13 10:37:54 +0300
commit54ce032ba173a656bd68c1493aa05d7a4da723cb (patch)
tree5c3479cb3948faabb96944d5aaa182f239e438a2 /vnext/src/components
parenta0ce096f73df72af0a03fe906587c72744555db8 (diff)
UserInfo: do not update state when unmounted
Diffstat (limited to 'vnext/src/components')
-rw-r--r--vnext/src/components/UserInfo.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/vnext/src/components/UserInfo.js b/vnext/src/components/UserInfo.js
index d772d76e..b08355f8 100644
--- a/vnext/src/components/UserInfo.js
+++ b/vnext/src/components/UserInfo.js
@@ -12,13 +12,21 @@ import SearchBox from './SearchBox';
import './UserInfo.css';
+let isMounted;
+
export default function UserInfo(props) {
const [user, setUser] = useState({ uname: props.user, uid: 0 });
useEffect(() => {
+ isMounted = true;
info(user.uname).then(response => {
- setUser(response.data);
- props.onUpdate && props.onUpdate(response.data);
+ if (isMounted) {
+ setUser(response.data);
+ props.onUpdate && props.onUpdate(response.data);
+ }
});
+ return () => {
+ isMounted = false;
+ };
});
return (
<>