-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(fe): apply error boundary for main directory (#2241)
* feat(fe): install suspensive, implement ErrorFallback component, apply ErrorBoundary to home page * chore(fe): fix pnpm-lock.yaml * feat(fe): add retry button in FetchErrorFallback * feat(fe): apply ErrorBoundary * chore(fe): remove console logging * chore(fe): specify importing type ErrorBoundaryFallbackProps * chore(fe): narrow the scope of ErrorBoundary in contest page
- Loading branch information
Showing
5 changed files
with
196 additions
and
97 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
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use client' | ||
|
||
import type { ErrorBoundaryFallbackProps } from '@suspensive/react' | ||
import { useRouter } from 'next/navigation' | ||
import { startTransition, useState } from 'react' | ||
import { RiAlertFill } from 'react-icons/ri' | ||
import { Button } from './shadcn/button' | ||
|
||
export default function FetchErrorFallback({ | ||
reset | ||
}: ErrorBoundaryFallbackProps) { | ||
const router = useRouter() | ||
const [isResetting, setIsResetting] = useState(false) | ||
|
||
const handleRetry = () => { | ||
setIsResetting(true) | ||
|
||
startTransition(() => { | ||
router.refresh() | ||
reset() | ||
setIsResetting(false) | ||
}) | ||
} | ||
return ( | ||
<div className="flex w-full flex-col items-center py-6"> | ||
<RiAlertFill className="text-gray-300" size={42} /> | ||
<p className="text-2xl font-bold">Failed to load data</p> | ||
<Button | ||
onClick={() => handleRetry()} | ||
disabled={isResetting} | ||
className="mt-2" | ||
> | ||
Retry | ||
</Button> | ||
</div> | ||
) | ||
} |
Oops, something went wrong.