19 lines
393 B
TypeScript
19 lines
393 B
TypeScript
|
// File path: components/LoadingBoundary.tsx
|
||
|
import React, { Suspense } from 'react';
|
||
|
|
||
|
interface LoadingBoundaryProps {
|
||
|
children: React.ReactNode;
|
||
|
fallback?: React.ReactNode;
|
||
|
}
|
||
|
|
||
|
export const LoadingBoundary: React.FC<LoadingBoundaryProps> = ({
|
||
|
children,
|
||
|
fallback = <div>Loading...</div>
|
||
|
}) => {
|
||
|
return (
|
||
|
<Suspense fallback={fallback}>
|
||
|
{children}
|
||
|
</Suspense>
|
||
|
);
|
||
|
};
|