import React from "react"; import { View, Text } from "react-native"; import { getPost, getPosts, Post } from "../util/api"; import { PostView } from "./PostView"; import { style } from "../util/style"; import { SafeAreaView } from "react-native"; import { VirtualizedList } from "react-native"; type ItemData = { id: string; title: string; }; type ItemProps = { title: string; }; const Item = ({title}: ItemProps): JSX.Element => ( {title} ); export function PostsContainer(): JSX.Element { // const [posts, setPosts] = React.useState([]); // React.useEffect(() => { // refreshPosts(); // }, []); const getItemCount = (_data: unknown): number => 50; // function refreshPosts(): void { // async function fetchPosts(): Promise { // const posts = await getPosts(); // setPosts(posts); // } // fetchPosts(); // } // function getItemCount(): number { // return posts.length; // } const getItem = (_data: unknown, index: number): ItemData => ({ id: Math.random().toString(12).substring(0), title: `Item ${index + 1}`, }); // const getItem = async (data: any, index: number): Promise => { // const p = await getPost(index); // return p; // }; return ( } keyExtractor={(item: ItemData) => item.id} getItemCount={getItemCount} getItem={getItem} /> ); }