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; return () => { isMounted = false; }; }, [props.user, user.uid, user.uri]); return (
{ user.uname ? {user.avatar ? {`${user.uname}`} : } : }
{user.uname} {props.children}
); } export default Avatar; Avatar.propTypes = { user: UserType, link: PropTypes.string, style: PropTypes.object, children: PropTypes.node };