File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
packages/react-web3-icons/src Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -3,11 +3,13 @@ import React, { JSX } from "react";
33
44import { Web3IconType } from "../../icons/full" ;
55import { IconComponentBaseProps , symbolToComponentName } from "../../utils" ;
6+ import { omit } from "../../utils/omit" ;
67import { IconPlaceholder } from "../Base/IconPlaceholder" ;
78
8- export type LoadableIconProps = IconComponentBaseProps & {
9+ export type LoadableIconProps = Omit < IconComponentBaseProps , "loader" > & {
910 iconKey : Web3IconType | string ;
1011 abbreviation : string ;
12+ fallback ?: Pick < IconComponentBaseProps , "loader" > ;
1113 fallbackComponent ?: JSX . Element ;
1214} ;
1315
@@ -22,7 +24,12 @@ export const LoadableIcon = loadable(
2224 const mode = mono ? "mono" : "full" ;
2325 const componentName = symbolToComponentName ( iconKey ) ;
2426 try {
25- return import ( `../icons/${ mode } /${ componentName } ` ) ;
27+ const iconEsModule = await import ( `../icons/${ mode } /${ componentName } ` ) ;
28+ const IconComponent = iconEsModule . default ;
29+ const imageComponentProps = omit ( props , [ "fallback" ] ) ;
30+ return {
31+ default : ( ) => < IconComponent { ...imageComponentProps } /> ,
32+ } ;
2633 } catch ( err ) {
2734 if ( fallbackComponent ) {
2835 return {
Original file line number Diff line number Diff line change 1+ export const omit = < T extends Record < string , unknown > > (
2+ obj : T ,
3+ keys : ( keyof T ) [ ] ,
4+ ) => {
5+ const exclude = new Set ( keys ) ;
6+ return Object . fromEntries (
7+ ( Object . entries ( obj ) as [ keyof T , T [ keyof T ] ] [ ] ) . filter ( ( [ key ] ) => {
8+ return ! exclude . has ( key ) ;
9+ } ) ,
10+ ) ;
11+ } ;
You can’t perform that action at this time.
0 commit comments