Fixing useEffect warnings
This commit is contained in:
@@ -44,13 +44,20 @@ let Media = (props) => {
|
||||
const [videosFiles, setVideosFiles] = useState([]);
|
||||
const [poster, setPoster] = useState('');
|
||||
const [loaded, setLoaded] = useState(false);
|
||||
useEffect(async () => {
|
||||
if (!videosId[1]) return 0;
|
||||
let videoObj = await API.getVideo(videosId[1]);
|
||||
if(videoObj && videoObj.files){
|
||||
setVideosFiles(videoObj.files);
|
||||
setPoster(videoObj.pictures.sizes[4].link);
|
||||
}
|
||||
useEffect(() => {
|
||||
let subscribed = true;
|
||||
let getData = async () => {
|
||||
if (!videosId[1]) return 0;
|
||||
let videoObj = await API.getVideo(videosId[1]);
|
||||
if(videoObj && videoObj.files && subscribed){
|
||||
setVideosFiles(videoObj.files);
|
||||
setPoster(videoObj.pictures.sizes[4].link);
|
||||
}
|
||||
};
|
||||
getData();
|
||||
return ()=>{
|
||||
subscribed = false;
|
||||
};
|
||||
}, [props.content])
|
||||
const video = videosFiles.length ? (
|
||||
loaded ? <VideoPlayer videosFiles={videosFiles} poster={poster} videoId={videosId[1]} /> :
|
||||
|
||||
@@ -58,7 +58,7 @@ let Post = (props) => {
|
||||
return (
|
||||
<Card style={styles.card}>
|
||||
<Card.Content>
|
||||
<Hyperlink linkDefault={ true }>
|
||||
<Hyperlink linkDefault={ true } linkStyle={{}}>
|
||||
{!post.nonOrganicType ?
|
||||
<View>
|
||||
<Text style={styles.userName}>
|
||||
|
||||
@@ -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