Notifications view improvement and some cleaning

This commit is contained in:
Adolfo Reyna
2022-12-11 22:17:58 -05:00
parent 18a37c64c0
commit 90be0f05bb
6 changed files with 52 additions and 45 deletions

View File

@@ -0,0 +1,28 @@
import React, { useState, useEffect } from 'react';
import { ScrollView } from 'react-native';
import API from './../API.js';
import Post from './Post.js';
let SinglePostComponent = ({ postId }) => {
let [post, setPost] = useState({});
useEffect(() => {
let subscribed = true;
let getData = async ()=>{
if (postId){
let post = await API.getPost(postId);
if(subscribed) setPost(post);
}
}
getData();
return () => {
subscribed = false;
}
}, [postId]);
return (post._id ? (
<ScrollView>
<Post post={post}/>
</ScrollView>
) : null);
};
export default React.memo(SinglePostComponent);