Last update to useEffect methods
This commit is contained in:
@@ -31,13 +31,20 @@ let CourseCard = ({ 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") : '';
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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 && 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") : '';
|
||||
@@ -53,7 +60,7 @@ let ProfileCard = ({ profileid, hideIcon, profileObj }) => {
|
||||
return (
|
||||
<Card style={styles.content}>
|
||||
<Card.Content>
|
||||
<Avatar.Image size={150} source={{ uri: photoUrl }} />
|
||||
<Avatar.Image size={150} source={{ uri: photoUrl }} />
|
||||
<Title onPress={onPress} numberOfLines={1}>
|
||||
<Text>
|
||||
{profile.profile && profile.profile.firstName} {profile.profile && profile.profile.lastName}
|
||||
@@ -74,7 +81,7 @@ const styles = StyleSheet.create({
|
||||
margin: 4,
|
||||
width: "50%",
|
||||
},
|
||||
centerItems:{
|
||||
centerItems: {
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user