File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed
Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @programmer_network/yail" ,
3- "version" : " 1.1.4 " ,
3+ "version" : " 1.1.5 " ,
44 "description" : " Programmer Network's official UI library for React" ,
55 "author" : " Aleksandar Grbic - (https://programmer.network)" ,
66 "publishConfig" : {
Original file line number Diff line number Diff line change @@ -10,6 +10,10 @@ import {
1010
1111import { IIconProps } from "./types" ;
1212
13+ const iconModules = import . meta. glob < {
14+ default : ComponentType < SVGProps < SVGElement > > ;
15+ } > ( "../Icons/*.tsx" ) ;
16+
1317const iconCache : Record <
1418 string ,
1519 React . LazyExoticComponent < ComponentType < SVGProps < SVGElement > > >
@@ -24,18 +28,18 @@ const Icon: FC<IIconProps> = props => {
2428 return iconCache [ iconName ] ;
2529 }
2630
27- const Component = lazy ( ( ) =>
28- import ( `../Icons/${ iconName } .tsx` ) . catch ( ( ) => {
29- setError ( true ) ;
30- return { default : ( ) => null } ;
31- } )
32- ) ;
31+ const importer = iconModules [ `../Icons/${ iconName } .tsx` ] ;
32+ if ( ! importer ) {
33+ setError ( true ) ;
34+ return null ;
35+ }
3336
37+ const Component = lazy ( importer ) ;
3438 iconCache [ iconName ] = Component ;
3539 return Component ;
3640 } , [ iconName ] ) ;
3741
38- if ( error ) {
42+ if ( error || ! IconComponent ) {
3943 return null ;
4044 }
4145
You can’t perform that action at this time.
0 commit comments