"use client"; import React, { Component, ErrorInfo, ReactNode } from 'react'; import { Button } from '@/components/ui/button'; import { RefreshCw } from 'lucide-react'; interface Props { children: ReactNode; fallback?: ReactNode; } interface State { hasError: boolean; error?: Error; } class ChunkErrorBoundary extends Component { constructor(props: Props) { super(props); this.state = { hasError: false }; } static getDerivedStateFromError(error: Error): State { // Check if it's a chunk loading error if (error.name === 'ChunkLoadError' || error.message.includes('Loading chunk')) { return { hasError: true, error }; } return { hasError: false }; } componentDidCatch(error: Error, errorInfo: ErrorInfo) { console.error('Chunk loading error:', error, errorInfo); // If it's a chunk loading error, try to reload the page if (error.name === 'ChunkLoadError' || error.message.includes('Loading chunk')) { this.setState({ hasError: true, error }); } } handleRetry = () => { // Clear the error state and reload the page this.setState({ hasError: false, error: undefined }); window.location.reload(); }; render() { if (this.state.hasError) { if (this.props.fallback) { return this.props.fallback; } return (

Chunk Loading Error

There was an issue loading a part of the application. This usually happens when the application has been updated.

{process.env.NODE_ENV === 'development' && this.state.error && (
Error Details (Development)
                  {this.state.error.message}
                
)}
); } return this.props.children; } } export default ChunkErrorBoundary;