Fix single post scrolling for long content and comments

This commit is contained in:
Adolfo Reyna
2026-02-24 16:36:41 -05:00
parent 53df0699a7
commit fc6f740fd2
2 changed files with 15 additions and 12 deletions

View File

@@ -1,5 +1,5 @@
import React, { useMemo, useRef, useState } from 'react';
import { Text, Pressable, FlatList, StyleSheet, View, Share, Alert, Linking, Animated, PanResponder } from 'react-native';
import { Text, Pressable, StyleSheet, View, Share, Alert, Linking, Animated, PanResponder } from 'react-native';
import { Button, Card, Chip } from 'react-native-paper';
import API from './../API.js';
import UserName from './UserName.js';
@@ -71,9 +71,6 @@ let Post = (props) => {
API.removePostBookmark(post._id)
}
}
const renderComment = ({ item }) => (
<Comment comment={item} postid={post._id} />
);
const handleTagPress = (tag) => {
// Alert.alert("tag pressed", `You pressed the tag: ${tag}`);
// You can navigate to another screen or perform any other action here
@@ -278,11 +275,15 @@ let Post = (props) => {
{showCommentsB && <NewComment postid={post._id} newComentAdded={newComentAdded} />}
{
showCommentsB &&
<FlatList
data={post.comments}
renderItem={renderComment}
keyExtractor={item => item.createdAt}
/>
<View>
{post.comments.map((comment, index) => (
<Comment
key={`${comment?.createdAt || "comment"}-${index}`}
comment={comment}
postid={post._id}
/>
))}
</View>
}
</Card>
);