Skip to content

Commit ac9d1b0

Browse files
committed
fix: empty memory issue
1 parent 2c7008d commit ac9d1b0

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

components/empty/index.tsx

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineComponent } from 'vue';
1+
import { defineComponent, h } from 'vue';
22
import type { CSSProperties, ExtractPropTypes } from 'vue';
33
import classNames from '../_util/classNames';
44
import LocaleReceiver from '../locale-provider/LocaleReceiver';
@@ -11,9 +11,6 @@ import useConfigInject from '../config-provider/hooks/useConfigInject';
1111

1212
import useStyle from './style';
1313

14-
const defaultEmptyImg = <DefaultEmptyImg />;
15-
const simpleEmptyImg = <SimpleEmptyImg />;
16-
1714
interface Locale {
1815
description?: string;
1916
}
@@ -40,13 +37,16 @@ const Empty = defineComponent({
4037
return () => {
4138
const prefixCls = prefixClsRef.value;
4239
const {
43-
image = slots.image?.() || defaultEmptyImg,
40+
image: mergedImage = slots.image?.() || h(DefaultEmptyImg),
4441
description = slots.description?.() || undefined,
4542
imageStyle,
4643
class: className = '',
4744
...restProps
4845
} = { ...props, ...attrs };
49-
46+
const image =
47+
typeof mergedImage === 'function' ? (mergedImage as () => VueNode)() : mergedImage;
48+
const isNormal =
49+
typeof image === 'object' && 'type' in image && (image.type as any).PRESENTED_IMAGE_SIMPLE;
5050
return wrapSSR(
5151
<LocaleReceiver
5252
componentName="Empty"
@@ -64,7 +64,7 @@ const Empty = defineComponent({
6464
return (
6565
<div
6666
class={classNames(prefixCls, className, hashId.value, {
67-
[`${prefixCls}-normal`]: image === simpleEmptyImg,
67+
[`${prefixCls}-normal`]: isNormal,
6868
[`${prefixCls}-rtl`]: direction.value === 'rtl',
6969
})}
7070
{...restProps}
@@ -85,7 +85,7 @@ const Empty = defineComponent({
8585
},
8686
});
8787

88-
Empty.PRESENTED_IMAGE_DEFAULT = defaultEmptyImg;
89-
Empty.PRESENTED_IMAGE_SIMPLE = simpleEmptyImg;
88+
Empty.PRESENTED_IMAGE_DEFAULT = () => h(DefaultEmptyImg);
89+
Empty.PRESENTED_IMAGE_SIMPLE = () => h(SimpleEmptyImg);
9090

9191
export default withInstall(Empty);

0 commit comments

Comments
 (0)