Skip to content

Commit

Permalink
Fix error throw and for useTransition demo (#6510)
Browse files Browse the repository at this point in the history
  • Loading branch information
lunaleaps authored Dec 21, 2023
1 parent 3bf64e5 commit 3009d76
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/MDX/Sandpack/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
13 changes: 7 additions & 6 deletions src/content/reference/react/useTransition.md
Original file line number Diff line number Diff line change
Expand Up @@ -1520,15 +1520,15 @@ import { ErrorBoundary } from "react-error-boundary";
export function AddCommentContainer() {
return (
<ErrorBoundary fallback={<p>⚠️Something went wrong</p>}>
<AddCommentButton />
<AddCommentButton />
</ErrorBoundary>
);
}

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");
}
}

Expand All @@ -1544,9 +1544,10 @@ function AddCommentButton() {
// so error gets thrown
addComment();
});
}}>
Add comment
</button>
}}
>
Add comment
</button>
);
}
```
Expand Down

0 comments on commit 3009d76

Please sign in to comment.