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:
parent
70a7eefa22
commit
9a18dd8162
4 changed files with 11 additions and 44 deletions
|
@ -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 (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue