Date: Mon, 25 May 2026 15:15:22 +0200
Subject: [PATCH 2/2] Address review: simpler example, shorter nav label
---
.../examples/AsyncUserCodeErrors.json | 2 +-
src/App.tsx | 2 +-
src/routes/examples/AsyncUserCodeErrors.tsx | 21 ++++++-------------
3 files changed, 8 insertions(+), 17 deletions(-)
diff --git a/public/generated/examples/AsyncUserCodeErrors.json b/public/generated/examples/AsyncUserCodeErrors.json
index 813926a..03cb33f 100644
--- a/public/generated/examples/AsyncUserCodeErrors.json
+++ b/public/generated/examples/AsyncUserCodeErrors.json
@@ -1,3 +1,3 @@
{
- "html": "import { useEffect } from \"react\";
\nimport { ErrorBoundary, useErrorBoundary } from \"react-error-boundary\";
\n
\nfunction UserProfileContainer({ username }: { username: string }) {
\n return (
\n <ErrorBoundary
\n fallback={<p>Could not load profile</p>}
\n resetKeys={[username]}
\n >
\n <UserProfile username={username} />
\n </ErrorBoundary>
\n );
\n}
\n
\nfunction UserProfile({ username }: { username: string }) {
\n const { showBoundary } = useErrorBoundary();
\n
\n useEffect(() => {
\n let cancelled = false;
\n
\n fetchUserProfile(username).then(
\n (response) => {
\n if (!cancelled) {
\n
\n }
\n },
\n (error) => {
\n if (!cancelled) {
\n showBoundary(error);
\n }
\n },
\n );
\n
\n return () => {
\n cancelled = true;
\n };
\n }, [showBoundary, username]);
\n
\n return null;
\n}
"
+ "html": "import { useEffect } from \"react\";
\nimport { ErrorBoundary, useErrorBoundary } from \"react-error-boundary\";
\n
\nfunction UserProfileContainer({ username }: { username: string }) {
\n return (
\n <ErrorBoundary
\n fallback={<p>Could not load profile</p>}
\n resetKeys={[username]}
\n >
\n <UserProfile username={username} />
\n </ErrorBoundary>
\n );
\n}
\n
\nfunction UserProfile({ username }: { username: string }) {
\n const { showBoundary } = useErrorBoundary();
\n
\n useEffect(() => {
\n fetchGreeting(username).then(
\n (response) => {
\n
\n },
\n (error) => {
\n
\n showBoundary(error);
\n },
\n );
\n }, [showBoundary, username]);
\n
\n return null;
\n}
"
}
\ No newline at end of file
diff --git a/src/App.tsx b/src/App.tsx
index f7febee..4f71e11 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -29,7 +29,7 @@ export default function App() {
Error logging
- Events and async functions
+ Events & async
Transition errors
diff --git a/src/routes/examples/AsyncUserCodeErrors.tsx b/src/routes/examples/AsyncUserCodeErrors.tsx
index 5d5a88b..643aa93 100644
--- a/src/routes/examples/AsyncUserCodeErrors.tsx
+++ b/src/routes/examples/AsyncUserCodeErrors.tsx
@@ -16,25 +16,16 @@ function UserProfile({ username }: { username: string }) {
const { showBoundary } = useErrorBoundary();
useEffect(() => {
- let cancelled = false;
-
- fetchUserProfile(username).then(
+ fetchGreeting(username).then(
(response) => {
- if (!cancelled) {
- // Set data in state and re-render
- response; // hidden
- }
+ // Set data in state and re-render ...
+ response; // hidden
},
(error) => {
- if (!cancelled) {
- showBoundary(error);
- }
+ // Show error boundary
+ showBoundary(error);
},
);
-
- return () => {
- cancelled = true;
- };
}, [showBoundary, username]);
return null;
@@ -44,4 +35,4 @@ function UserProfile({ username }: { username: string }) {
export { UserProfileContainer };
-async function fetchUserProfile(_: string) {}
+async function fetchGreeting(_: string) {}