芝麻web文件管理V1.00
编辑当前文件:/home/freeclou/app.optimyar.com/backend/.cache/admin/src/containers/ErrorBoundary/index.js
/** * * 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;