-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nextjs): app router support (#1071)
- Loading branch information
Showing
4 changed files
with
174 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use client'; // Error components must be Client Components | ||
|
||
// eslint-disable-next-line import/no-unresolved | ||
import { useEffect } from 'react' | ||
import { Honeybadger } from '@honeybadger-io/react' | ||
|
||
/** | ||
* error.[js|tsx]: https://nextjs.org/docs/app/building-your-application/routing/error-handling | ||
* global-error.[js|tsx]: https://nextjs.org/docs/app/building-your-application/routing/error-handling#handling-errors-in-layouts | ||
* | ||
* This component is called when: | ||
* - on the server, when data fetching methods throw or reject | ||
* - on the client, when getInitialProps throws or rejects | ||
* - on the client, when a React lifecycle method (render, componentDidMount, etc) throws or rejects | ||
* and was caught by the built-in Next.js error boundary | ||
*/ | ||
export default function Error({ | ||
error, | ||
reset, | ||
}) { | ||
useEffect(() => { | ||
Honeybadger.notify(error) | ||
}, [error]) | ||
|
||
return ( | ||
<div> | ||
<h2>Something went wrong!</h2> | ||
<button | ||
onClick={ | ||
// Attempt to recover by trying to re-render the segment | ||
() => reset() | ||
} | ||
> | ||
Try again | ||
</button> | ||
</div> | ||
) | ||
} |
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,41 @@ | ||
'use client'; // Error components must be Client Components | ||
|
||
// eslint-disable-next-line import/no-unresolved | ||
import { useEffect } from 'react' | ||
import { Honeybadger } from '@honeybadger-io/react' | ||
|
||
/** | ||
* error.[js|tsx]: https://nextjs.org/docs/app/building-your-application/routing/error-handling | ||
* global-error.[js|tsx]: https://nextjs.org/docs/app/building-your-application/routing/error-handling#handling-errors-in-layouts | ||
* | ||
* This component is called when: | ||
* - on the server, when data fetching methods throw or reject | ||
* - on the client, when getInitialProps throws or rejects | ||
* - on the client, when a React lifecycle method (render, componentDidMount, etc) throws or rejects | ||
* and was caught by the built-in Next.js error boundary | ||
*/ | ||
export default function Error({ | ||
error, | ||
reset, | ||
}: { | ||
error: Error; | ||
reset: () => void; | ||
}) { | ||
useEffect(() => { | ||
Honeybadger.notify(error) | ||
}, [error]) | ||
|
||
return ( | ||
<div> | ||
<h2>Something went wrong!</h2> | ||
<button | ||
onClick={ | ||
// Attempt to recover by trying to re-render the segment | ||
() => reset() | ||
} | ||
> | ||
Try again | ||
</button> | ||
</div> | ||
) | ||
} |