From 2812569d3964a9493ee7716e952e4aa59a8b21b2 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 12 Apr 2019 00:13:43 +0300 Subject: Make Avatar pure component --- vnext/src/components/Avatar.js | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) (limited to 'vnext/src/components/Avatar.js') diff --git a/vnext/src/components/Avatar.js b/vnext/src/components/Avatar.js index fed68ed1..dda5449f 100644 --- a/vnext/src/components/Avatar.js +++ b/vnext/src/components/Avatar.js @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react'; +import React, { memo } from 'react'; import PropTypes from 'prop-types'; import { Link } from 'react-router-dom'; @@ -6,34 +6,15 @@ 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.uname, user.uri) { - fetchUserUri(user.uri).then(response => { - if (isMounted) { - setUser(response.data); - } - }); - } - return () => { - isMounted = false; - }; - }, [props.user]); +function Avatar({ user, style, link, children}) { return ( -