diff --git a/packages/grafana-ui/src/components/Icon/Icon.tsx b/packages/grafana-ui/src/components/Icon/Icon.tsx index 59135b9a89f..f6bb0645f2f 100644 --- a/packages/grafana-ui/src/components/Icon/Icon.tsx +++ b/packages/grafana-ui/src/components/Icon/Icon.tsx @@ -42,65 +42,67 @@ const getIconStyles = (theme: GrafanaTheme2) => { }; }; -export const Icon = React.forwardRef( - ({ size = 'md', type = 'default', name, className, style, title = '', ...rest }, ref) => { - const styles = useStyles2(getIconStyles); +export const Icon = React.memo( + React.forwardRef( + ({ size = 'md', type = 'default', name, className, style, title = '', ...rest }, ref) => { + const styles = useStyles2(getIconStyles); - if (!isIconName(name)) { - console.warn('Icon component passed an invalid icon name', name); - } - - // handle the deprecated 'fa fa-spinner' - const iconName: IconName = name === 'fa fa-spinner' ? 'spinner' : name; - - const svgSize = getSvgSize(size); - const svgHgt = svgSize; - const svgWid = name.startsWith('gf-bar-align') ? 16 : name.startsWith('gf-interp') ? 30 : svgSize; - const svgPath = getIconPath(iconName, type); - - const composedClassName = cx( - styles.icon, - className, - type === 'mono' ? { [styles.orange]: name === 'favorite' } : '', - { - [styles.spin]: iconName === 'spinner', + if (!isIconName(name)) { + console.warn('Icon component passed an invalid icon name', name); } - ); - return ( - - } - {...rest} - /> - ); - } + ); + + return ( + + } + {...rest} + /> + ); + } + ) ); Icon.displayName = 'Icon';