From 3009d764ed362ae749c5835cbc38783dd29bfd57 Mon Sep 17 00:00:00 2001
From: Luna
Date: Wed, 20 Dec 2023 20:58:16 -0400
Subject: [PATCH] Fix error throw and for useTransition demo (#6510)
---
src/components/MDX/Sandpack/Preview.tsx | 2 +-
src/content/reference/react/useTransition.md | 13 +++++++------
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/components/MDX/Sandpack/Preview.tsx b/src/components/MDX/Sandpack/Preview.tsx
index 059645550..9669e5f4f 100644
--- a/src/components/MDX/Sandpack/Preview.tsx
+++ b/src/components/MDX/Sandpack/Preview.tsx
@@ -54,7 +54,7 @@ export function Preview({
// When throwing a new Error in Sandpack - we want to disable the dev error dialog
// to show the Error Boundary fallback
- if (rawError && rawError.message.includes(`throw Error('Example error')`)) {
+ if (rawError && rawError.message.includes('Example Error:')) {
rawError = null;
}
diff --git a/src/content/reference/react/useTransition.md b/src/content/reference/react/useTransition.md
index 37e89c0c9..49df279fb 100644
--- a/src/content/reference/react/useTransition.md
+++ b/src/content/reference/react/useTransition.md
@@ -1520,15 +1520,15 @@ import { ErrorBoundary } from "react-error-boundary";
export function AddCommentContainer() {
return (
⚠️Something went wrong
}>
-
+
);
}
function addComment(comment) {
// For demonstration purposes to show Error Boundary
- if(comment == null){
- throw Error('Example error')
+ if (comment == null) {
+ throw new Error("Example Error: An error thrown to trigger error boundary");
}
}
@@ -1544,9 +1544,10 @@ function AddCommentButton() {
// so error gets thrown
addComment();
});
- }}>
- Add comment
-
+ }}
+ >
+ Add comment
+
);
}
```