import React, { useState } from 'react'; import { ErrorBoundary, ErrorBoundaryAlert } from './ErrorBoundary'; import { withCenteredStory } from '@grafana/ui/src/utils/storybook/withCenteredStory'; import mdx from './ErrorBoundary.mdx'; import { Button } from '../Button'; import { ErrorWithStack } from './ErrorWithStack'; import { Alert } from '../Alert/Alert'; export default { title: 'General/ErrorBoundary', component: ErrorBoundary, decorators: [withCenteredStory], parameters: { docs: { page: mdx, }, }, }; const BuggyComponent = () => { const [count, setCount] = useState(0); if (count > 2) { throw new Error('Crashed'); } return (

Increase the count to 3 to trigger error

); }; export const Basic = () => { return ( {({ error }) => { if (error) { return ; } return ; }} ); }; export const WithStack = () => { return ; }; export const BoundaryAlert = () => { return ( ); };