From 487561b78207e59fbad7c55a1efaa19783560b6f Mon Sep 17 00:00:00 2001 From: Stephen Wade Date: Tue, 23 Jul 2024 21:07:08 -0400 Subject: [PATCH] fix(react): Memoize offline components --- components/react/src/offline.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/react/src/offline.ts b/components/react/src/offline.ts index 4cd4aa5..8784910 100644 --- a/components/react/src/offline.ts +++ b/components/react/src/offline.ts @@ -1,4 +1,4 @@ -import { forwardRef, createElement, type Ref } from 'react'; +import { forwardRef, createElement, memo, type Ref } from 'react'; import type { IconifyIcon, IconifyJSON } from '@iconify/types'; import type { IconifyIconSize } from '@iconify/utils/lib/customisations/defaults'; import { defaultIconProps } from '@iconify/utils/lib/icon/defaults'; @@ -63,25 +63,25 @@ type IconComponentType = (props: IconProps) => JSX.Element; * * @param props - Component properties */ -export const Icon = forwardRef((props, ref) => +export const Icon = memo(forwardRef((props, ref) => IconComponent({ ...props, _ref: ref, }) -) as IconComponentType; +)) as IconComponentType; /** * Inline icon (has negative verticalAlign that makes it behave like icon font) * * @param props - Component properties */ -export const InlineIcon = forwardRef((props, ref) => +export const InlineIcon = memo(forwardRef((props, ref) => IconComponent({ inline: true, ...props, _ref: ref, }) -) as IconComponentType; +)) as IconComponentType; /** * Add icon to storage, allowing to call it by name