Skip to content
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

Log loader/action errors in dev from default error boundary #10286

Merged
merged 2 commits into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/console-log-loader-error.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-router": patch
---

Log loader/action errors to the console in dev for easier stack trace evaluation
9 changes: 7 additions & 2 deletions packages/react-router/lib/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -468,14 +468,19 @@ function DefaultErrorComponent() {

let devInfo = null;
if (__DEV__) {
console.error(
"Error handled by React Router default ErrorBoundary:",
error
);

devInfo = (
<>
<p>💿 Hey developer 👋</p>
<p>
You can provide a way better UX than this when your app throws errors
by providing your own&nbsp;
<code style={codeStyles}>ErrorBoundary</code> prop on&nbsp;
<code style={codeStyles}>&lt;Route&gt;</code>
<code style={codeStyles}>ErrorBoundary</code> or{" "}
<code style={codeStyles}>errorElement</code> prop on your route.
</p>
</>
);
Expand Down