1 import PropTypes from 'prop-types';
2 import React from 'react';
4 import ErrorMessage from './ErrorMessage';
6 class ErrorBoundary extends React.Component {
14 static getDerivedStateFromError(error) {
18 componentDidCatch(error, errorInfo) {
19 console.log(error, errorInfo);
23 const { children } = this.props;
24 const { error } = this.state;
26 return <ErrorMessage error={error} />;
32 ErrorBoundary.propTypes = {
33 children: PropTypes.node,
36 export default ErrorBoundary;