mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-30 22:39:34 +08:00
6b4f94785c
* chore: use React.useContext replace <Context.ConfigConsumer /> * add
34 lines
998 B
TypeScript
34 lines
998 B
TypeScript
import React, { useContext } from 'react';
|
|
import { ConfigContext } from '.';
|
|
import type { ConfigConsumerProps } from '.';
|
|
import Empty from '../empty';
|
|
|
|
interface EmptyProps {
|
|
componentName?: string;
|
|
}
|
|
|
|
const DefaultRenderEmpty: React.FC<EmptyProps> = (props) => {
|
|
const { componentName } = props;
|
|
const { getPrefixCls } = useContext<ConfigConsumerProps>(ConfigContext);
|
|
const prefix = getPrefixCls('empty');
|
|
switch (componentName) {
|
|
case 'Table':
|
|
case 'List':
|
|
return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />;
|
|
case 'Select':
|
|
case 'TreeSelect':
|
|
case 'Cascader':
|
|
case 'Transfer':
|
|
case 'Mentions':
|
|
return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} className={`${prefix}-small`} />;
|
|
/* istanbul ignore next */
|
|
default:
|
|
// Should never hit if we take all the component into consider.
|
|
return <Empty />;
|
|
}
|
|
};
|
|
|
|
export type RenderEmptyHandler = (componentName?: string) => React.ReactNode;
|
|
|
|
export default DefaultRenderEmpty;
|