Core/demo/DemoFailingComponent.tsx
Madeorsk cbedfa9d52
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
Add error boundaries and a default one with notifications.
2024-09-25 17:27:52 +02:00

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