import React, { Component } from 'react';
import { SomethingWentWrong } from './components/SomethingWentWrong';
export class ErrorBoundary extends Component {
  constructor(props) {
    super(props);
    this.state = {
      hasError: false,
      errorMessage: new Error('')
    };
  }

  static getDerivedStateFromError(error) {
    return {
      hasError: true,
      errorMessage: error
    };
  }

  componentDidCatch(error, errorInfo) {
    var {
      logError
    } = this.props;
    logError(error, errorInfo.componentStack);
  }

  render() {
    var {
      hasError
    } = this.state;
    var {
      children
    } = this.props;

    if (hasError) {
      return React.createElement(SomethingWentWrong, {
        header: "Uh oh! Something went wrong!",
        actionMessage: "Try refreshing the page to correct the problem."
      });
    }

    return children || React.createElement(React.Fragment, null);
  }

}
//# sourceMappingURL=ErrorBoundary.js.map