-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: async component in client components
- Loading branch information
1 parent
b26aab4
commit 2d8645b
Showing
6 changed files
with
50 additions
and
29 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 |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import type { FC } from 'react'; | ||
import type { ReactNode } from 'react'; | ||
|
||
import { Screen } from '@/components/page/TopPage'; | ||
|
||
const TopPage: FC = () => <Screen />; | ||
const TopPage = ({ | ||
searchParams, | ||
}: { | ||
searchParams: { page?: number }; | ||
}): ReactNode => <Screen page={searchParams.page ?? 1} />; | ||
|
||
export default TopPage; |
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
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
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,16 +1,39 @@ | ||
import type { FC } from 'react'; | ||
import { Suspense } from 'react'; | ||
|
||
import { worksRepository } from '../../repository'; | ||
|
||
import { WorkCardsContainer } from './presentations'; | ||
import { WorkCardsErrorPresentation } from './presentations/error'; | ||
import { WorkCardsLoadingPresentation } from './presentations/loading'; | ||
|
||
import { ErrorBoundary } from '@/libs/ErrorBoundary'; | ||
|
||
export const WorkCards: FC = () => ( | ||
type Props = { | ||
page: number; | ||
}; | ||
export const WorkCards: FC<Props> = ({ page }) => ( | ||
<ErrorBoundary fallback={<WorkCardsErrorPresentation />}> | ||
<Suspense fallback={<WorkCardsLoadingPresentation />}> | ||
<WorkCardsContainer /> | ||
<WorkCardsFetchContainer page={page} /> | ||
</Suspense> | ||
</ErrorBoundary> | ||
); | ||
|
||
const WorkCardsFetchContainer: FC<{ page: number }> = async ({ page }) => { | ||
const { works, totalCount } = await worksRepository.getWorks({ | ||
query: { | ||
page, | ||
}, | ||
}); | ||
console.log(totalCount); | ||
return ( | ||
<WorkCardsContainer | ||
works={works} | ||
currentPage={page} | ||
totalPage={ | ||
Math.ceil(totalCount / 30) == 0 ? 1 : Math.ceil(totalCount / 30) | ||
} | ||
/> | ||
); | ||
}; |
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
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