1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 15:59:41 +02:00

fix console error for feather icon (#7305)

This commit is contained in:
Richard Wei 2022-07-25 20:11:48 +12:00 committed by GitHub
parent 70a7eefa22
commit 9a18dd8162
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 44 deletions

View file

@ -1,6 +1,6 @@
import clsx from 'clsx';
import { ComponentType, ReactNode, useEffect } from 'react';
import featherIcons from 'feather-icons';
import { ComponentType, ReactNode } from 'react';
import * as featherIcons from 'react-feather';
import { isValidElementType } from 'react-is';
import Svg, { SvgIcons } from './Svg';
@ -30,12 +30,6 @@ interface Props {
}
export function Icon({ icon, feather, className, mode, size }: Props) {
useEffect(() => {
if (feather) {
featherIcons.replace();
}
}, [feather]);
const classes = clsx(
className,
'icon',
@ -59,14 +53,12 @@ export function Icon({ icon, feather, className, mode, size }: Props) {
}
if (feather) {
return (
<i
data-feather={icon}
className={classes}
aria-hidden="true"
role="img"
/>
);
const iconName = icon
.split('-')
.map((s) => s.slice(0, 1).toUpperCase() + s.slice(1))
.join('') as keyof typeof featherIcons;
const IconComponent = featherIcons[iconName];
return <IconComponent className={classes} />;
}
return (