Finally the InfiniteTweetList is it's own component declared as such:
import Link from "next/link"
import InfiniteScroll from "react-infinite-scroll-component"
import { ProfileImage } from "./ProfileImage"
import { useSession } from "next-auth/react"
import { VscHeartFilled, VscHeart } from "react-icons/vsc"
import { IconHoverEffect } from "./IconHoverEffect"
type Tweet = {
id: string
content: string
createdAt: Date
likeCount: number
likedByMe: boolean
user: { id: string; image: string | null; name: string | null}
}
type InfiniteTweetListProps = {
isLoading: boolean
isError: boolean
hasMore: boolean
fetchNewTweets: () => Promise<unknown>
tweets?: Tweet[]
}
export function InfiniteTweetList({tweets, isError, isLoading, fetchNewTweets, hasMore}: InfiniteTweetListProps) {
if(isLoading) return <h1>Loading...</h1>
if(isError) return <h1>Error Loading Tweet</h1>
if(tweets == null || tweets.length == 0) {
return <h1 className="my-4 text-center text-2xl text-gray-500">There's Nothing Here...</h1>
}
return <ul>
<InfiniteScroll
dataLength={tweets.length}
next={fetchNewTweets}
hasMore={hasMore}
loader={"Loading..."}>
{tweets.map(tweet => {
return <TweetCard key={tweet.id} {...tweet} />
})}
</InfiniteScroll>
</ul>
}
}