@@ -2,11 +2,11 @@ import * as React from 'react';
22import classNames from 'classnames' ;
33
44import { devUseWarning } from '../_util/warning' ;
5+ import { useComponentConfig } from '../config-provider/context' ;
56import { useLocale } from '../locale' ;
67import DefaultEmptyImg from './empty' ;
78import SimpleEmptyImg from './simple' ;
89import useStyle from './style' ;
9- import { useComponentConfig } from '../config-provider/context' ;
1010
1111const defaultEmptyImg = < DefaultEmptyImg /> ;
1212const simpleEmptyImg = < SimpleEmptyImg /> ;
@@ -40,7 +40,7 @@ const Empty: CompoundedComponent = (props) => {
4040 className,
4141 rootClassName,
4242 prefixCls : customizePrefixCls ,
43- image = defaultEmptyImg ,
43+ image,
4444 description,
4545 children,
4646 imageStyle,
@@ -56,6 +56,7 @@ const Empty: CompoundedComponent = (props) => {
5656 style : contextStyle ,
5757 classNames : contextClassNames ,
5858 styles : contextStyles ,
59+ image : contextImage ,
5960 } = useComponentConfig ( 'empty' ) ;
6061
6162 const prefixCls = getPrefixCls ( 'empty' , customizePrefixCls ) ;
@@ -66,12 +67,14 @@ const Empty: CompoundedComponent = (props) => {
6667 const des = typeof description !== 'undefined' ? description : locale ?. description ;
6768 const alt = typeof des === 'string' ? des : 'empty' ;
6869
70+ const mergedImage = image ?? contextImage ?? defaultEmptyImg ;
71+
6972 let imageNode : React . ReactNode = null ;
7073
71- if ( typeof image === 'string' ) {
72- imageNode = < img alt = { alt } src = { image } /> ;
74+ if ( typeof mergedImage === 'string' ) {
75+ imageNode = < img alt = { alt } src = { mergedImage } /> ;
7376 } else {
74- imageNode = image ;
77+ imageNode = mergedImage ;
7578 }
7679
7780 // ============================= Warning ==============================
@@ -91,7 +94,7 @@ const Empty: CompoundedComponent = (props) => {
9194 prefixCls ,
9295 contextClassName ,
9396 {
94- [ `${ prefixCls } -normal` ] : image === simpleEmptyImg ,
97+ [ `${ prefixCls } -normal` ] : mergedImage === simpleEmptyImg ,
9598 [ `${ prefixCls } -rtl` ] : direction === 'rtl' ,
9699 } ,
97100 className ,
0 commit comments