|
1 | | -import { forwardRef, lazy, Suspense, SVGAttributes, useContext } from 'react'; |
2 | | -import { IconName, LucideIconName } from './iconNames.js'; |
3 | | -import { CustomIconName, customIcons } from './customGlyphs/index.js'; |
4 | | -import dynamicIconImports from 'lucide-react/dynamicIconImports.js'; |
5 | | -import clsx from 'clsx'; |
6 | | -import { ICON_CLASS_NAME } from './constants.js'; |
7 | 1 | import { Slot } from '@radix-ui/react-slot'; |
8 | | -import cls from './Icon.module.css'; |
| 2 | +import clsx from 'clsx'; |
| 3 | +import dynamicIconImports from 'lucide-react/dynamicIconImports.js'; |
| 4 | +import { forwardRef, lazy, Suspense, SVGAttributes, useContext } from 'react'; |
9 | 5 | import { ButtonContext } from '../button/ButtonContext.js'; |
| 6 | +import { ErrorBoundary } from '../errorBoundary/ErrorBoundary.js'; |
10 | 7 | import { Spinner } from '../spinner/Spinner.js'; |
| 8 | +import { ICON_CLASS_NAME } from './constants.js'; |
| 9 | +import { CustomIconName, customIcons } from './customGlyphs/index.js'; |
| 10 | +import cls from './Icon.module.css'; |
| 11 | +import { IconName, LucideIconName } from './iconNames.js'; |
11 | 12 |
|
12 | 13 | export type { IconName } from './iconNames.js'; |
13 | 14 |
|
@@ -55,9 +56,11 @@ export const Icon = forwardRef<SVGSVGElement, IconProps>(function Icon({ name, c |
55 | 56 | const LucideIcon = lazy(dynamicIconImports[name as LucideIconName]); |
56 | 57 |
|
57 | 58 | return ( |
58 | | - <Suspense fallback={<IconFallback />}> |
59 | | - <LucideIcon {...rest} absoluteStrokeWidth={absoluteStrokeWidth} className={clsx(ICON_CLASS_NAME, cls.icon, className)} ref={ref} /> |
60 | | - </Suspense> |
| 59 | + <ErrorBoundary fallback={<IconFallback ref={ref} />}> |
| 60 | + <Suspense fallback={<IconFallback ref={ref} />}> |
| 61 | + <LucideIcon {...rest} absoluteStrokeWidth={absoluteStrokeWidth} className={clsx(ICON_CLASS_NAME, cls.icon, className)} ref={ref} /> |
| 62 | + </Suspense> |
| 63 | + </ErrorBoundary> |
61 | 64 | ); |
62 | 65 | }); |
63 | 66 |
|
|
0 commit comments