Fixing useEffect warnings

This commit is contained in:
aeroreyna
2022-11-19 20:45:32 -05:00
parent 4e1112fbf4
commit a313822c27
6 changed files with 81 additions and 56 deletions

View File

@@ -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") : '';