import React, { useState, useEffect } from 'react'; import { Text, ScrollView, FlatList, StyleSheet } from 'react-native'; import { Avatar, Button, Card, Title, Paragraph } from 'react-native-paper'; import API from './../API.js'; import UserName from './UserName.js'; import Media from './Media.js'; import Comment from "./Comment"; import NewComment from './NewComment.js'; let Post = (props) => { const viewer = props.viewer; let [showCommentsB, changeshowCommentsB] = useState(false); let [post, changePost] = useState(props.post); let toProfileText = post.toProfile && post.toProfile !== post.profileid ? {">"} : undefined; let cleanContent = post.content.replace(/@[A-z]+:.+\w/g, ''); const newComentAdded = (commentData) => { //add to comments let newPostObj = { ...post }; newPostObj.comments.push(commentData); changePost(newPostObj); }; const renderComment = ({ item }) => ( ); return ( {toProfileText} {cleanContent} {showCommentsB && } { showCommentsB && item.createdAt} /> } ); } export default React.memo(Post); const styles = StyleSheet.create({ userName: { fontSize: 14, fontWeight: 'bold', marginBottom: 5, fontSize: 18, }, card: { margin: 8, backgroundColor: "#FFFFFF" }, comment: { margin: 8, marginTop: 0, padding: 8 } });