Skip to content

Commit b9f8d9d

Browse files
committed
feat: Errors can have children too
1 parent 73991b3 commit b9f8d9d

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

src/components/ErrorComponent.tsx

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ interface ErrorProps {
1313
error: Error | { message: string | ReactNode };
1414
title?: string;
1515
showReturnToHome?: boolean;
16+
children?: ReactNode;
1617
}
1718

18-
export function ErrorComponent({ className, error, title, showReturnToHome }: ErrorProps) {
19+
export function ErrorComponent({ className, error, title, showReturnToHome, children }: ErrorProps) {
1920
const { user, isLoading: isUserLoading } = useOverallAuth();
2021
const defaultCloudRoute = getDefaultSignedInCloudRouteForUser(user);
2122

@@ -27,23 +28,27 @@ export function ErrorComponent({ className, error, title, showReturnToHome }: Er
2728
</CardTitle>
2829
<CardDescription>{error.message}</CardDescription>
2930
</CardHeader>
30-
{showReturnToHome !== false && (<CardContent>
31-
{user && !isUserLoading ? (
32-
<Link to={isLocalStudio ? defaultInstanceRoute : defaultCloudRoute}>
33-
<Button>
34-
{' '}
35-
<ArrowLeft /> Return to Home
36-
</Button>
37-
</Link>
38-
) : (
39-
<Link to="/sign-in">
40-
<Button>
41-
{' '}
42-
<ArrowLeft /> Go to Sign In Page
43-
</Button>
44-
</Link>
31+
<CardContent>
32+
{children}
33+
{showReturnToHome !== false && (user && !isUserLoading
34+
? (
35+
<Link to={isLocalStudio ? defaultInstanceRoute : defaultCloudRoute}>
36+
<Button>
37+
{' '}
38+
<ArrowLeft /> Return to Home
39+
</Button>
40+
</Link>
41+
)
42+
: (
43+
<Link to="/sign-in">
44+
<Button>
45+
{' '}
46+
<ArrowLeft /> Go to Sign In Page
47+
</Button>
48+
</Link>
49+
)
4550
)}
46-
</CardContent>)}
51+
</CardContent>
4752
</Card>
4853
);
4954
}

0 commit comments

Comments
 (0)