Skip to content
This repository was archived by the owner on Feb 15, 2025. It is now read-only.

Commit e2a5ca3

Browse files
committed
fixed icon types
1 parent 84136ce commit e2a5ca3

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
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+
};
Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
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

94
type FunctionPropertyNames<T> = {
105
[K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;
116
}[keyof T] &
127
string;
138

149
export type IconTypes<
15-
T = IconKeyMap,
10+
T = typeof IconKeyMap,
1611
M = FunctionPropertyNames<Required<T>>
1712
> = M;
1813

@@ -23,9 +18,8 @@ type Props = {
2318

2419
const 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

3125
export default Icons;

0 commit comments

Comments
 (0)