This repository was archived by the owner on Feb 15, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +11
-10
lines changed
src/components/other/Icons Expand file tree Collapse file tree 2 files changed +11
-10
lines changed Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import { FiStar , FiZap } from 'react-icons/all' ;
3+
4+ export const IconKeyMap = {
5+ star : ( props ) => < FiStar { ...props } /> ,
6+ zap : ( props ) => < FiZap { ...props } /> ,
7+ } ;
Original file line number Diff line number Diff line change 1- import React , { useState } from 'react' ;
2- import { FiStar , FiZap } from 'react-icons/all' ;
3-
4- class IconKeyMap {
5- star = ( props ) => < FiStar { ...props } /> ;
6- zap = ( props ) => < FiZap { ...props } /> ;
7- }
1+ import React from 'react' ;
2+ import { IconKeyMap } from './icons' ;
83
94type FunctionPropertyNames < T > = {
105 [ K in keyof T ] : T [ K ] extends ( ...args : any [ ] ) => any ? K : never ;
116} [ keyof T ] &
127 string ;
138
149export type IconTypes <
15- T = IconKeyMap ,
10+ T = typeof IconKeyMap ,
1611 M = FunctionPropertyNames < Required < T > >
1712> = M ;
1813
@@ -23,9 +18,8 @@ type Props = {
2318
2419const Icons : React . FC < Props > = ( props ) => {
2520 const { type } = props ;
26- const [ iconKeyMap ] = useState ( new IconKeyMap ( ) ) ;
2721
28- return iconKeyMap [ type ] ( props ) || < div > Icon '{ type } ' doesn't exists!</ div > ;
22+ return IconKeyMap [ type ] ( props ) || < div > Icon '{ type } ' doesn't exists!</ div > ;
2923} ;
3024
3125export default Icons ;
You can’t perform that action at this time.
0 commit comments