Skip to content

Commit aa91d76

Browse files
committed
refactor(Result): 使用Function组件重构 Class组件
1 parent ca555b5 commit aa91d76

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

packages/core/src/Result/index.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,15 @@ export interface ResultProps extends ViewProps {
4949
message?: React.ReactNode;
5050
}
5151

52-
export default class Result extends Component<ResultProps> {
53-
static defaultProps: ResultProps = {};
54-
render() {
55-
const { style, title, message, img, ...otherProps } = this.props;
56-
return (
57-
<View style={[styles.defalut, style]} {...otherProps}>
58-
{img}
59-
{title && <MaybeTextOrView style={styles.title}>{title}</MaybeTextOrView>}
60-
{message && <MaybeTextOrView style={styles.message}>{message}</MaybeTextOrView>}
61-
</View>
62-
);
63-
}
52+
export default function Result(props: ResultProps) {
53+
const { style, title, message, img, ...otherProps } = props;
54+
return (
55+
<View style={[styles.defalut, style]} {...otherProps}>
56+
{img}
57+
{title && <MaybeTextOrView style={styles.title}>{title}</MaybeTextOrView>}
58+
{message && <MaybeTextOrView style={styles.message}>{message}</MaybeTextOrView>}
59+
</View>
60+
);
6461
}
62+
63+
Result.defaultProps = {} as ResultProps;

0 commit comments

Comments
 (0)