Fix error throw and for useTransition demo (#6510)

This commit is contained in:
Luna
2023-12-20 20:58:16 -04:00
committed by GitHub
parent 3bf64e5ffd
commit 3009d764ed
2 changed files with 8 additions and 7 deletions

View File

@@ -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;
}

View File

@@ -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");
}
}
@@ -1544,9 +1544,10 @@ function AddCommentButton() {
// so error gets thrown
addComment();
});
}}>
Add comment
</button>
}}
>
Add comment
</button>
);
}
```