Fixing useEffect warnings
This commit is contained in:
@@ -33,28 +33,31 @@ let Profile = ({ navigation, route }) => {
|
||||
let [Posts, setPosts] = useState([]);
|
||||
let [profile, setProfile] = useState({});
|
||||
|
||||
useEffect(async () => {
|
||||
useEffect(() => {
|
||||
let subscribed = true;
|
||||
setPosts([]);
|
||||
if (route.params && route.params.profileid) {
|
||||
console.log('Loading Cache Profile:' + route.params.profileid);
|
||||
await API.getUserProfile(route.params.profileid).then((profileObj) => {
|
||||
if(!subscribed) return 0;
|
||||
let profile = profileObj.profile
|
||||
setProfile(profileObj);
|
||||
navigation.setOptions({ title: profile.firstName + " " + profile.lastName });
|
||||
});
|
||||
await getProfilePosts(route.params.profileid).then(setPosts);
|
||||
console.log('Loaded Cache Profile:' + route.params.profileid);
|
||||
API.getPosts(route.params.profileid).then((data) => {
|
||||
if(!subscribed) return 0;
|
||||
setPosts(data);
|
||||
storeProfilePosts(route.params.profileid, data);
|
||||
console.log('Store Cache Profile:' + route.params.profileid);
|
||||
});
|
||||
} else {
|
||||
navigation.navigate('Feed')
|
||||
const getData = async () => {
|
||||
setPosts([]);
|
||||
if (route.params && route.params.profileid) {
|
||||
console.log('Loading Cache Profile:' + route.params.profileid);
|
||||
await API.getUserProfile(route.params.profileid).then((profileObj) => {
|
||||
if(!subscribed) return 0;
|
||||
let profile = profileObj.profile
|
||||
setProfile(profileObj);
|
||||
navigation.setOptions({ title: profile.firstName + " " + profile.lastName });
|
||||
});
|
||||
await getProfilePosts(route.params.profileid).then(setPosts);
|
||||
console.log('Loaded Cache Profile:' + route.params.profileid);
|
||||
API.getPosts(route.params.profileid).then((data) => {
|
||||
if(!subscribed) return 0;
|
||||
setPosts(data);
|
||||
storeProfilePosts(route.params.profileid, data);
|
||||
console.log('Store Cache Profile:' + route.params.profileid);
|
||||
});
|
||||
} else {
|
||||
navigation.navigate('Feed')
|
||||
}
|
||||
}
|
||||
getData();
|
||||
return ()=>{
|
||||
subscribed = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user