mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-23 20:23:08 +00:00
Fix error throw and for useTransition demo (#6510)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user