Skip to content

Commit

Permalink
Merge pull request #11542 from qkiroc/fix/icon
Browse files Browse the repository at this point in the history
fix: 修复icon组件vendor报错
  • Loading branch information
hsm-lv authored Jan 24, 2025
2 parents dbea944 + 6b9d46d commit 0aa943d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/amis-ui/src/components/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,12 @@ function svgString2Dom(
if (vendorFn) {
const {icon: newIcon, style: newStyle} = vendorFn(icon, {
...extra,
width: style.width,
height: style.height
width: style?.width,
height: style?.height
});
icon = newIcon;
style = {
...style,
...(style || {}),
...newStyle
};
}
Expand All @@ -310,18 +310,17 @@ function svgString2Dom(

function LinkIcon({
icon,
vendor,
vendorFn,
options: {className, classNameProp, style, cx, classPrefix, events, extra}
}: {
icon: string;
vendor?: string;
vendorFn?: CustomVendorFn;
options: {
[propName: string]: any;
};
}) {
const [svgIcon, setSvgIcon] = React.useState<string>(icon);
const [svgType, setSvgType] = React.useState<string>('img');
const vendorFn = useMemo(() => getCustomVendor(vendor), [vendor]);

useEffect(() => {
if (icon.endsWith('.svg') && vendorFn) {
Expand Down Expand Up @@ -401,6 +400,7 @@ export function Icon({
testIdBuilder?: TestIdBuilder;
} & React.ComponentProps<any>) {
let cx = iconCx || cxClass;
const vendorFn = useMemo(() => getCustomVendor(vendor), [vendor]);

// style = {
// ...(style || {}),
Expand Down Expand Up @@ -551,7 +551,7 @@ export function Icon({
events,
extra
},
vendor
vendorFn
);
}

Expand All @@ -561,7 +561,7 @@ export function Icon({
return (
<LinkIcon
icon={icon}
vendor={vendor}
vendorFn={vendorFn}
options={{
className,
classNameProp,
Expand Down

0 comments on commit 0aa943d

Please sign in to comment.