diff --git a/frontend/src/map/LazyMaps.tsx b/frontend/src/map/LazyMaps.tsx index c2480c3..2d4bd94 100644 --- a/frontend/src/map/LazyMaps.tsx +++ b/frontend/src/map/LazyMaps.tsx @@ -1,4 +1,5 @@ -import { lazy, Suspense } from 'react' +import { Component, lazy, Suspense } from 'react' +import type { ReactNode } from 'react' import type { ProjectsMapAllProps } from './ProjectsMapAll' import type { ProjectsMapSingleProps } from './ProjectsMapSingle' @@ -17,18 +18,55 @@ function MapSkeleton({ className = '' }: { className?: string }) { return
} +/** + * مرز خطای نقشه — تبِ باز از پیش از استقرار، تکه‌های قدیمی را درخواست می‌کند + * که دیگر وجود ندارند (۴۰۴) و نقشه بی‌صدا می‌میرد. این مرز خطا را می‌گیرد و + * بارگیری دوبارهٔ کامل صفحه را پیشنهاد می‌دهد که تازه‌ترین نسخه را می‌آورد. + */ +class MapErrorBoundary extends Component<{ children: ReactNode; className?: string }, { failed: boolean }> { + state = { failed: false } + static getDerivedStateFromError() { + return { failed: true } + } + render() { + if (this.state.failed) { + return ( +
+

+ بارگیری نقشه ناموفق بود — نسخهٔ صفحه در این تب قدیمی است +

+ +
+ ) + } + return this.props.children + } +} + export function LazyProjectsMapAll(props: ProjectsMapAllProps) { return ( - }> - - + + }> + + + ) } export function LazyProjectsMapSingle(props: ProjectsMapSingleProps) { return ( - }> - - + + }> + + + ) }