From 61a5383f46cdfdf464da61ad180bd22296b0fc51 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 28 Apr 2024 08:42:11 +0300 Subject: [PATCH] chore(react): prevent rerendering on mount with ssr attr --- components/react/package.json | 2 +- components/react/src/iconify.ts | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/components/react/package.json b/components/react/package.json index 340ae22..ac0b0f5 100644 --- a/components/react/package.json +++ b/components/react/package.json @@ -2,7 +2,7 @@ "name": "@iconify/react", "description": "Iconify icon component for React.", "author": "Vjacheslav Trushkin", - "version": "5.0.0-beta.1", + "version": "5.0.0-beta.2", "publishConfig": { "access": "public", "tag": "next" diff --git a/components/react/src/iconify.ts b/components/react/src/iconify.ts index 7318977..6475603 100644 --- a/components/react/src/iconify.ts +++ b/components/react/src/iconify.ts @@ -288,16 +288,15 @@ function IconComponent(props: InternalIconProps): JSX.Element { // Mounted state, cleanup for loader useEffect(() => { setMounted(true); - updateState(); return cleanup; }, []); - // Icon changed + // Icon changed or component mounted useEffect(() => { if (mounted) { updateState(); } - }, [props.icon]); + }, [props.icon, mounted]); // Render icon const { name, data } = state;