import React from "react"; import Button from "~/components/Button"; import { connect } from "react-redux"; import { publicApi } from "~/redux/actions"; import appConfig from "~/config"; const { version } = appConfig; const agent = window.navigator.userAgent; class ErrorBoundary extends React.Component { constructor(props) { super(props); this.state = { error: false }; } static getDerivedStateFromError(error) { return { error }; } render() { if (this.state.error) { let errors = this.state.error.stack.split("\n"); if (errors[0].includes("dynamically imported")) { window.location.reload(true); return null; } // .filter((e) => !e.includes("node_module")); return (
خطای نمایشی
متاسفانه برای نمایش اطلاعات این صفحه خطایی وجود دارد {/* {errors[0].replace("ReferenceError:", "")} */}
{/*
{errors.slice(1).map((e, i) => (
{e}
))} */}
); } return this.props.children; } } export default connect( (state) => ({ loading: state.publicApi.loading, }), { report: publicApi.report } )(ErrorBoundary);