import React from 'react';
import PropTypes from 'prop-types';
import ServiceContext from '../services/context';
class PageErrorBoundary extends React.Component {
constructor(props) {
super(props);
this.state = { hasError: false };
}
componentDidCatch(error, info) {
console.error(error, info);
this.setState({
hasError: true,
});
}
render() {
const { hasError } = this.state;
if (hasError) {
return <span>Sorry, Something went wrong.</span>;
}
const { children } = this.props;
return children;
}
}
PageErrorBoundary.propTypes = {
children: PropTypes.node.isRequired,
};