2
0
mirror of https://github.com/iconify/iconify.git synced 2024-12-05 02:33:16 +00:00

chore(react): prevent rerendering on mount with ssr attr

This commit is contained in:
Vjacheslav Trushkin 2024-04-28 08:42:11 +03:00
parent e244ddea3d
commit 61a5383f46
2 changed files with 3 additions and 4 deletions

View File

@ -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"

View File

@ -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;