import React, { useState, useEffect } from 'react'; import PropTypes from 'prop-types'; import { Link } from 'react-router-dom'; import { UserType } from './Types'; import Icon from './Icon'; import { fetchUserUri } from '../api'; import './Avatar.css'; let isMounted; function Avatar(props) { const [user, setUser] = useState(props.user); useEffect(() => { setUser(props.user); isMounted = true; if (!user.uid && user.uri) { fetchUserUri(user.uri).then(response => { if (isMounted) { setUser(response.data); } }); return () => { isMounted = false; }; } }, [props.user]); return (