Skip to content

Commit a5c59ea

Browse files
author
rulishu
committed
refactor(Empty): 重构Empty为函数组件
1 parent 204cf1f commit a5c59ea

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

packages/core/src/Empty/index.tsx

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,17 @@ export interface EmptyProps extends FlexProps {
3838
children?: React.ReactNode;
3939
}
4040

41-
export default class Empty extends Component<EmptyProps> {
42-
static defaultProps: EmptyProps = {
43-
size: 64,
44-
label: '暂无数据',
45-
xml: iconStr,
46-
};
47-
render() {
48-
const { size, label, xml, labelStyle, children, ...props } = this.props;
49-
return (
50-
<Flex direction="column" justify="center" align="center" {...props}>
51-
{xml && <Icon xml={xml} size={size} />}
52-
{!!children
53-
? children
54-
: label &&
55-
typeof label === 'string' && <Text style={StyleSheet.flatten([styles.label, labelStyle])}>{label}</Text>}
56-
</Flex>
57-
);
58-
}
41+
export default function Empty(props: EmptyProps) {
42+
const { size = 64, label = '暂无数据', xml = iconStr, labelStyle, children, ...otherProps } = props;
43+
return (
44+
<Flex direction="column" justify="center" align="center" {...otherProps}>
45+
{xml && <Icon xml={xml} size={size} />}
46+
{!!children
47+
? children
48+
: label &&
49+
typeof label === 'string' && <Text style={StyleSheet.flatten([styles.label, labelStyle])}>{label}</Text>}
50+
</Flex>
51+
);
5952
}
6053

6154
const styles = StyleSheet.create({

0 commit comments

Comments
 (0)