27 lines
533 B
TypeScript
27 lines
533 B
TypeScript
|
import React from "react";
|
||
|
import {useErrorBoundary} from "react-error-boundary";
|
||
|
|
||
|
/**
|
||
|
* A simple demo failing component.
|
||
|
*/
|
||
|
export function DemoFailingComponent()
|
||
|
{
|
||
|
throw new Error("Proudly thrown error.");
|
||
|
return (<p>I will never be shown...</p>);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* A simple demo reset component.
|
||
|
*/
|
||
|
export function DemoResetComponent()
|
||
|
{
|
||
|
// Get error boundary.
|
||
|
const errorBoundary = useErrorBoundary();
|
||
|
|
||
|
return (
|
||
|
<button type={"button"} onClick={() => {
|
||
|
errorBoundary.resetBoundary();
|
||
|
}}>Reset to try again!</button>
|
||
|
);
|
||
|
}
|