/** * * ErrorBoundary * */ import React from 'react'; import PropTypes from 'prop-types'; class ErrorBoundary extends React.Component { // eslint-disable-line react/prefer-stateless-function state = { error: null, errorInfo: null }; componentDidCatch(error, errorInfo) { this.setState({ error, errorInfo, }); } render() { const { error, errorInfo } = this.state; if (errorInfo) { return (

Something went wrong.

{error && error.toString()}
{errorInfo.componentStack}
); } return this.props.children; } } ErrorBoundary.defaultProps = { children: null, }; ErrorBoundary.propTypes = { children: PropTypes.node, }; export default ErrorBoundary;