-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
45 Handles errors using react error boundaries #111
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of taking advantage of the router errorElement for route-level error messages.
I just have a few comments that need to be addressed.
src/components/error.tsx
Outdated
@@ -0,0 +1,13 @@ | |||
import React from "react" | |||
|
|||
const errorElement = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about calling this component RouterErrorElement
?
Please add jsDoc documentation for this component. Most important is to explain how it is to be used.
This component should also follow the Typescript pattern of our other components – see home.tsx.
|
||
const errorElement = () => { | ||
return ( | ||
<div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about the following message:
<h1>An Unexpected Error Has Occurred</h1>
<p>
To recover, try the following:
<ul>
<li>Refresh the browser</li>
<li>Go back to the <a href="/">home screen</a></li>
</ul>
</p>
When we have a support email address, we can add another bullet about contacting us.
My testing shows that React Router also sends the stack trace to the console as well as displaying the error component. Bonus! |
We should also pursue adding ErrorBoundaries in other places such as:
|
No description provided.