mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-22 01:05:34 +03:00
Fix icon doesn't refresh when changed
This commit is contained in:
parent
30403f835c
commit
3cab36f24c
1 changed files with 5 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
|||
import { memo } from 'preact/compat';
|
||||
import { useEffect, useState } from 'preact/hooks';
|
||||
import { useEffect, useRef, useState } from 'preact/hooks';
|
||||
|
||||
const SIZES = {
|
||||
s: 12,
|
||||
|
@ -127,14 +127,16 @@ function Icon({
|
|||
}
|
||||
|
||||
const [iconData, setIconData] = useState(ICONDATA[icon]);
|
||||
const currentIcon = useRef(icon);
|
||||
useEffect(() => {
|
||||
if (iconData) return;
|
||||
if (iconData && currentIcon.current === icon) return;
|
||||
(async () => {
|
||||
const iconB = await iconBlock();
|
||||
setIconData(iconB.default);
|
||||
ICONDATA[icon] = iconB.default;
|
||||
})();
|
||||
}, [iconData, icon, iconBlock]);
|
||||
currentIcon.current = icon;
|
||||
}, [icon]);
|
||||
|
||||
return (
|
||||
<span
|
||||
|
|
Loading…
Reference in a new issue