Fixing useEffect warnings
This commit is contained in:
@@ -28,12 +28,20 @@ let UserName = ({ profileid, hideIcon }) => {
|
||||
let [profile, setProfile] = useState({});
|
||||
const navigation = useNavigation();
|
||||
|
||||
useEffect(async () => {
|
||||
let cacheProfile = await getName(profileid);
|
||||
if (cacheProfile && cacheProfile.profile) setProfile(cacheProfile);
|
||||
let p = await API.getUserProfile(profileid).catch(() => { return {} });
|
||||
setProfile(p);
|
||||
storeName(profileid, p)
|
||||
useEffect(() => {
|
||||
let subscribed = true;
|
||||
let getData = async () => {
|
||||
let cacheProfile = await getName(profileid);
|
||||
if (cacheProfile && cacheProfile.profile && subscribed) setProfile(cacheProfile);
|
||||
let p = await API.getUserProfile(profileid).catch(() => { return {} });
|
||||
if (subscribed)
|
||||
setProfile(p);
|
||||
storeName(profileid, p)
|
||||
}
|
||||
getData();
|
||||
return () => {
|
||||
subscribed = false;
|
||||
};
|
||||
}, [profileid]);
|
||||
|
||||
let icon = profile._id ? (!profile.isGroup ? "person-outline" : "group") : '';
|
||||
|
||||
Reference in New Issue
Block a user