File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 1
1
import React , { lazy , Suspense } from 'react' ;
2
2
3
- const CodeBlock = lazy ( ( ) => import ( './CodeBlock' ) ) ;
3
+ // Lazy load with error boundary
4
+ const CodeBlock = lazy ( ( ) =>
5
+ import ( './CodeBlock' ) . catch ( ( ) => {
6
+ console . error ( 'Failed to load CodeBlock component' ) ;
7
+ // Return a fallback component on error
8
+ return { default : ( { children, className = '' } ) => (
9
+ < code className = { `block bg-gray-100 dark:bg-gray-800 p-3 rounded-lg overflow-x-auto my-4 text-gray-800 dark:text-gray-200 text-sm font-mono whitespace-pre-wrap break-words ${ className } ` } >
10
+ { children }
11
+ </ code >
12
+ ) } ;
13
+ } )
14
+ ) ;
4
15
5
16
const CodeBlockFallback = ( { children, className = '' } ) => (
6
17
< code className = { `block bg-gray-100 dark:bg-gray-800 p-3 rounded-lg overflow-x-auto my-4 text-gray-800 dark:text-gray-200 text-sm font-mono whitespace-pre-wrap break-words ${ className } ` } >
You can’t perform that action at this time.
0 commit comments