Last update to useEffect methods
This commit is contained in:
@@ -32,13 +32,20 @@ let ProfileCard = ({ profileid, hideIcon, profileObj }) => {
|
||||
let [profile, setProfile] = useState(profileObj || {});
|
||||
const navigation = useNavigation();
|
||||
|
||||
useEffect(async () => {
|
||||
if (profileObj._id) return 0;
|
||||
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;
|
||||
const getData = async () => {
|
||||
if (profileObj._id) return 0;
|
||||
let cacheProfile = await getName(profileid);
|
||||
if (cacheProfile && cacheProfile.profile) 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") : '';
|
||||
@@ -65,7 +72,7 @@ let ProfileCard = ({ profileid, hideIcon, profileObj }) => {
|
||||
<Text>
|
||||
<FollowButton profile={profile} />
|
||||
<Text><Icon name={"hail"} size={18} />
|
||||
{Object.keys(profile.subscribed).length}</Text>
|
||||
{Object.keys(profile.subscribed).length}</Text>
|
||||
</Text>
|
||||
</Card.Content>
|
||||
</Card>
|
||||
|
||||
Reference in New Issue
Block a user