Notifications view improvement and some cleaning
This commit is contained in:
28
components/SinglePostComponent.js
Normal file
28
components/SinglePostComponent.js
Normal 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);
|
||||
Reference in New Issue
Block a user