-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: profile follower, following list 마크업 및 데이터 연동
- Loading branch information
1 parent
5250ae2
commit 387fd9c
Showing
5 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from 'react'; | ||
import { Virtuoso } from 'react-virtuoso'; | ||
|
||
import { ProfileListItem } from '@/components/molecules'; | ||
|
||
import { ProfileFollowContent } from '../types'; | ||
|
||
type FollowVirtualList = { | ||
data: ProfileFollowContent[]; | ||
fetchNextData: () => void; | ||
}; | ||
export const FollowVirtualList = ({ | ||
data, | ||
fetchNextData, | ||
}: FollowVirtualList) => { | ||
const handleRangeChanged = (range: { endIndex: number }) => { | ||
const currentContentsLastIndex = data.length - 1; | ||
if (range.endIndex >= currentContentsLastIndex - 3) { | ||
void fetchNextData(); | ||
} | ||
}; | ||
|
||
return ( | ||
<Virtuoso | ||
data={data} | ||
overscan={300} | ||
useWindowScroll | ||
rangeChanged={handleRangeChanged} | ||
itemContent={(_, item) => <ProfileListItem isFollow={true} {...item} />} | ||
style={{ | ||
width: '100%', | ||
height: '100%', | ||
}} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './follow-virtual-list'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use client'; | ||
|
||
import { useFollowerList } from '../apis'; | ||
import { FollowVirtualList } from '../components'; | ||
|
||
export const FollowerSection = ({ id }: { id: number }) => { | ||
const { flattenData, hasNextPage, isFetchingNextPage, fetchNextPage } = | ||
useFollowerList(id); | ||
|
||
const fetchNextData = () => { | ||
if (hasNextPage && !isFetchingNextPage) { | ||
void fetchNextPage(); | ||
} | ||
}; | ||
|
||
return <FollowVirtualList data={flattenData} fetchNextData={fetchNextData} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use client'; | ||
|
||
import { useFollowingList } from '../apis'; | ||
import { FollowVirtualList } from '../components'; | ||
|
||
export const FollowingSection = ({ id }: { id: number }) => { | ||
const { flattenData, hasNextPage, isFetchingNextPage, fetchNextPage } = | ||
useFollowingList(id); | ||
|
||
const fetchNextData = () => { | ||
if (hasNextPage && !isFetchingNextPage) { | ||
void fetchNextPage(); | ||
} | ||
}; | ||
|
||
return <FollowVirtualList data={flattenData} fetchNextData={fetchNextData} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export * from './follow-tab'; | ||
export * from './follower-section'; | ||
export * from './following-section'; |