Skip to content

Commit d1d6864

Browse files
committed
refactor(Avatar): 使用函数组件重构 Class组件写法
1 parent a066e3d commit d1d6864

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/core/src/Avatar/index.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ export interface AvatarProps extends ViewProps {
3737
}
3838

3939
export default function Avatar(props: AvatarProps) {
40-
const { style, src = defaultImage, size = 40, shape = 'square', rounded = 3, imageProps, ...otherProps } = props;
40+
const { style, src, size, shape, rounded, imageProps, ...otherProps } = props;
41+
4142
return (
4243
<View
4344
style={[
@@ -56,3 +57,10 @@ export default function Avatar(props: AvatarProps) {
5657
</View>
5758
);
5859
}
60+
61+
Avatar.defaultProps = {
62+
src: defaultImage,
63+
shape: 'square',
64+
rounded: 3,
65+
size: 40,
66+
} as AvatarProps;

0 commit comments

Comments
 (0)