import { Component, ReactNode } from 'react'; import { Button } from 'reactstrap'; import { SimpleCard } from '../utils/SimpleCard'; interface ErrorHandlerState { hasError: boolean; } export const ErrorHandler = ( { location }: Window, { error }: Console, ) => class extends Component { public constructor(props: object) { super(props); this.state = { hasError: false }; } public static getDerivedStateFromError(): ErrorHandlerState { return { hasError: true }; } public componentDidCatch(e: Error): void { if (process.env.NODE_ENV !== 'development') { error(e); } } public render(): ReactNode { const { hasError } = this.state; if (hasError) { return (

Oops! This is awkward :S

It seems that something went wrong. Try refreshing the page or just click this button.


); } const { children } = this.props; return children; } };