Skip to content

Commit 8f70296

Browse files
committed
fix: remove TypeScript warnings
1 parent d8944a3 commit 8f70296

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/CIcon.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export interface CIconProps extends HTMLAttributes<SVGSVGElement> {
1717
/**
1818
* Use for replacing default CIcon component classes. Prop is overriding the 'size' prop.
1919
*/
20-
customClassName?: string | object | string[] // eslint-disable-line @typescript-eslint/ban-types
20+
customClassName?: string | string[] // eslint-disable-line @typescript-eslint/ban-types
2121
/**
2222
* Name of the icon placed in React object or SVG content.
2323
*/
@@ -98,20 +98,18 @@ export const CIcon = forwardRef<SVGSVGElement, CIconProps>(
9898

9999
useMemo(() => setChange(change + 1), [_icon, JSON.stringify(_icon)])
100100

101-
const iconName = useMemo(
102-
() =>
103-
_icon && typeof _icon === 'string' && _icon.includes('-') ? toCamelCase(_icon) : _icon,
104-
[change],
105-
)
106-
107101
const titleCode = title ? `<title>${title}</title>` : ''
108102

109103
const code = useMemo(() => {
104+
const iconName =
105+
_icon && typeof _icon === 'string' && _icon.includes('-') ? toCamelCase(_icon) : _icon
106+
110107
if (Array.isArray(_icon)) {
111108
return _icon
112109
}
110+
113111
if (typeof _icon === 'string' && React['icons']) {
114-
return React['icons'][iconName]
112+
return React['icons'][iconName as string]
115113
}
116114
}, [change])
117115

@@ -127,8 +125,6 @@ export const CIcon = forwardRef<SVGSVGElement, CIconProps>(
127125
return rest['viewBox'] || `0 0 ${scale}`
128126
})()
129127

130-
// render
131-
132128
const _className = customClassName
133129
? classNames(customClassName)
134130
: classNames(

0 commit comments

Comments
 (0)