Skip to content

Commit c4af786

Browse files
edgarlrLuca Forstner
andauthored
Update nextjs guide global-error.tsx example types (#8740)
Co-authored-by: Luca Forstner <[email protected]>
1 parent 95d08ce commit c4af786

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/platforms/javascript/guides/nextjs/manual-setup.mdx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,14 @@ Create a [Custom Next.js Global Error component](https://nextjs.org/docs/app/bui
112112
"use client";
113113

114114
import * as Sentry from "@sentry/nextjs";
115-
import Error from "next/error";
115+
import NextError from "next/error";
116116
import { useEffect } from "react";
117117

118-
export default function GlobalError({ error }: { error: Error }) {
118+
export default function GlobalError({
119+
error,
120+
}: {
121+
error: Error & { digest?: string };
122+
}) {
119123
useEffect(() => {
120124
Sentry.captureException(error);
121125
}, [error]);
@@ -124,7 +128,7 @@ export default function GlobalError({ error }: { error: Error }) {
124128
<html>
125129
<body>
126130
{/* This is the default Next.js error component but it doesn't allow omitting the statusCode property yet. */}
127-
<Error statusCode={undefined as any} />
131+
<NextError statusCode={undefined as any} />
128132
</body>
129133
</html>
130134
);
@@ -135,7 +139,7 @@ export default function GlobalError({ error }: { error: Error }) {
135139
"use client";
136140

137141
import * as Sentry from "@sentry/nextjs";
138-
import Error from "next/error";
142+
import NextError from "next/error";
139143
import { useEffect } from "react";
140144

141145
export default function GlobalError({ error }) {
@@ -147,7 +151,7 @@ export default function GlobalError({ error }) {
147151
<html>
148152
<body>
149153
{/* This is the default Next.js error component. */}
150-
<Error />
154+
<NextError />
151155
</body>
152156
</html>
153157
);
@@ -163,7 +167,7 @@ This means, that if you want to report errors that are caught by `error.js` file
163167
import { useEffect } from "react";
164168
import * as Sentry from "@sentry/nextjs";
165169

166-
export default function Error({
170+
export default function ErrorPage({
167171
error,
168172
}: {
169173
error: Error & { digest?: string };
@@ -187,7 +191,7 @@ export default function Error({
187191
import { useEffect } from "react";
188192
import * as Sentry from "@sentry/nextjs";
189193

190-
export default function Error({ error }) {
194+
export default function ErrorPage({ error }) {
191195
useEffect(() => {
192196
// Log the error to Sentry
193197
Sentry.captureException(error);

0 commit comments

Comments
 (0)