Skip to content

Commit

Permalink
refactoring: use typedef FC
Browse files Browse the repository at this point in the history
  • Loading branch information
Rustin170506 committed Mar 28, 2020
1 parent 1805a6e commit 9eee0ef
Show file tree
Hide file tree
Showing 21 changed files with 24 additions and 27 deletions.
2 changes: 1 addition & 1 deletion components/button/button-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface ButtonGroupProps {
prefixCls?: string;
}

const ButtonGroup: React.FunctionComponent<ButtonGroupProps> = props => (
const ButtonGroup: React.FC<ButtonGroupProps> = props => (
<ConfigConsumer>
{({ getPrefixCls, direction }: ConfigConsumerProps) => {
const { prefixCls: customizePrefixCls, size, className, ...others } = props;
Expand Down
2 changes: 1 addition & 1 deletion components/card/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface CardGridProps {
hoverable?: boolean;
}

const Grid: React.FunctionComponent<CardGridProps> = props => (
const Grid: React.FC<CardGridProps> = props => (
<ConfigConsumer>
{({ getPrefixCls }: ConfigConsumerProps) => {
const { prefixCls: customizePrefixCls, className, hoverable = true, ...others } = props;
Expand Down
2 changes: 1 addition & 1 deletion components/card/Meta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface CardMetaProps {
description?: React.ReactNode;
}

const Meta: React.FunctionComponent<CardMetaProps> = props => (
const Meta: React.FC<CardMetaProps> = props => (
<ConfigConsumer>
{({ getPrefixCls }: ConfigConsumerProps) => {
const {
Expand Down
4 changes: 2 additions & 2 deletions components/config-provider/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ interface ConstructorProps {
export function withConfigConsumer<ExportProps extends BasicExportProps>(config: ConsumerConfig) {
return function withConfigConsumerFunc<ComponentDef>(
Component: IReactComponent,
): React.FunctionComponent<ExportProps> & ComponentDef {
): React.FC<ExportProps> & ComponentDef {
// Wrap with ConfigConsumer. Since we need compatible with react 15, be care when using ref methods
const SFC = ((props: ExportProps) => (
<ConfigConsumer>
Expand All @@ -66,7 +66,7 @@ export function withConfigConsumer<ExportProps extends BasicExportProps>(config:
return <Component {...configProps} {...props} prefixCls={prefixCls} />;
}}
</ConfigConsumer>
)) as React.FunctionComponent<ExportProps> & ComponentDef;
)) as React.FC<ExportProps> & ComponentDef;

const cons: ConstructorProps = Component.constructor as ConstructorProps;
const name = (cons && cons.displayName) || Component.name || 'Component';
Expand Down
3 changes: 1 addition & 2 deletions components/descriptions/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export interface DescriptionsItemProps {
span?: number;
}

const DescriptionsItem: React.FunctionComponent<DescriptionsItemProps> = ({ children }) =>
children as JSX.Element;
const DescriptionsItem: React.FC<DescriptionsItemProps> = ({ children }) => children as JSX.Element;

export default DescriptionsItem;
2 changes: 1 addition & 1 deletion components/divider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface DividerProps {
style?: React.CSSProperties;
}

const Divider: React.FunctionComponent<DividerProps> = props => (
const Divider: React.FC<DividerProps> = props => (
<ConfigConsumer>
{({ getPrefixCls }: ConfigConsumerProps) => {
const {
Expand Down
2 changes: 1 addition & 1 deletion components/page-header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const renderChildren = (prefixCls: string, children: React.ReactNode) => {
return <div className={`${prefixCls}-content`}>{children}</div>;
};

const PageHeader: React.FunctionComponent<PageHeaderProps> = props => (
const PageHeader: React.FC<PageHeaderProps> = props => (
<ConfigConsumer>
{({ getPrefixCls, pageHeader, direction }: ConfigConsumerProps) => {
const {
Expand Down
2 changes: 1 addition & 1 deletion components/progress/Circle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function getStrokeColor({ successPercent, strokeColor }: CircleProps) {
return [null, color];
}

const Circle: React.FunctionComponent<CircleProps> = props => {
const Circle: React.FC<CircleProps> = props => {
const {
prefixCls,
width,
Expand Down
2 changes: 1 addition & 1 deletion components/progress/Line.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const handleGradient = (strokeColor: ProgressGradient) => {
return { backgroundImage: `linear-gradient(${direction}, ${from}, ${to})` };
};

const Line: React.FunctionComponent<LineProps> = props => {
const Line: React.FC<LineProps> = props => {
const {
prefixCls,
percent,
Expand Down
2 changes: 1 addition & 1 deletion components/progress/Steps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interface StepsProps extends ProgressProps {
size?: ProgressSize;
}

const Steps: React.FunctionComponent<StepsProps> = props => {
const Steps: React.FC<StepsProps> = props => {
const {
size = 'default',
steps,
Expand Down
2 changes: 1 addition & 1 deletion components/result/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const renderIcon = (prefixCls: string, { status, icon }: ResultProps) => {
const renderExtra = (prefixCls: string, { extra }: ResultProps) =>
extra && <div className={`${prefixCls}-extra`}>{extra}</div>;

export interface ResultType extends React.FunctionComponent<ResultProps> {
export interface ResultType extends React.FC<ResultProps> {
PRESENTED_IMAGE_404: React.ReactNode;
PRESENTED_IMAGE_403: React.ReactNode;
PRESENTED_IMAGE_500: React.ReactNode;
Expand Down
2 changes: 1 addition & 1 deletion components/statistic/Number.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interface NumberProps extends FormatConfig {
value: valueType;
}

const StatisticNumber: React.FunctionComponent<NumberProps> = props => {
const StatisticNumber: React.FC<NumberProps> = props => {
const { value, formatter, precision, decimalSeparator, groupSeparator = '', prefixCls } = props;

let valueNode: React.ReactNode;
Expand Down
2 changes: 1 addition & 1 deletion components/statistic/Statistic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface StatisticProps extends FormatConfig {
suffix?: React.ReactNode;
}

const Statistic: React.FunctionComponent<StatisticProps & ConfigConsumerProps> = props => {
const Statistic: React.FC<StatisticProps & ConfigConsumerProps> = props => {
const {
prefixCls,
className,
Expand Down
2 changes: 1 addition & 1 deletion components/timeline/Timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface TimelineProps {
}

export default class Timeline extends React.Component<TimelineProps, any> {
static Item: React.FunctionComponent<TimeLineItemProps> = TimelineItem;
static Item: React.FC<TimeLineItemProps> = TimelineItem;

static defaultProps = {
reverse: false,
Expand Down
2 changes: 1 addition & 1 deletion components/timeline/TimelineItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface TimeLineItemProps {
label?: React.ReactNode;
}

const TimelineItem: React.FunctionComponent<TimeLineItemProps> = props => (
const TimelineItem: React.FC<TimeLineItemProps> = props => (
<ConfigConsumer>
{({ getPrefixCls }: ConfigConsumerProps) => {
const {
Expand Down
4 changes: 1 addition & 3 deletions components/typography/Paragraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import Base, { BlockProps } from './Base';

export interface ParagraphProps extends BlockProps {}

const Paragraph: React.FunctionComponent<ParagraphProps> = props => (
<Base {...props} component="div" />
);
const Paragraph: React.FC<ParagraphProps> = props => <Base {...props} component="div" />;

export default Paragraph;
2 changes: 1 addition & 1 deletion components/typography/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface TextProps extends BlockProps {
ellipsis?: boolean;
}

const Text: React.FunctionComponent<TextProps> = ({ ellipsis, ...restProps }) => {
const Text: React.FC<TextProps> = ({ ellipsis, ...restProps }) => {
warning(
typeof ellipsis !== 'object',
'Typography.Text',
Expand Down
2 changes: 1 addition & 1 deletion components/typography/Title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const TITLE_ELE_LIST = tupleNum(1, 2, 3, 4);

export type TitleProps = Omit<BlockProps & { level?: typeof TITLE_ELE_LIST[number] }, 'strong'>;

const Title: React.FunctionComponent<TitleProps> = props => {
const Title: React.FC<TitleProps> = props => {
const { level = 1, ...restProps } = props;
let component: string;

Expand Down
2 changes: 1 addition & 1 deletion site/theme/template/IconDisplay/CopyableIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface CopyableIconProps {
onCopied: (type: string, text: string) => any;
}

const CopyableIcon: React.FunctionComponent<CopyableIconProps> = ({
const CopyableIcon: React.FC<CopyableIconProps> = ({
name,
isNew,
justCopied,
Expand Down
6 changes: 3 additions & 3 deletions site/theme/template/IconDisplay/themeIcons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface CustomIconComponentProps {
['aria-hidden']?: React.AriaAttributes['aria-hidden'];
}

export const FilledIcon: React.FunctionComponent<CustomIconComponentProps> = props => {
export const FilledIcon: React.FC<CustomIconComponentProps> = props => {
const path =
'M864 64H160C107 64 64 107 64 160v' +
'704c0 53 43 96 96 96h704c53 0 96-43 96-96V16' +
Expand All @@ -24,7 +24,7 @@ export const FilledIcon: React.FunctionComponent<CustomIconComponentProps> = pro
);
};

export const OutlinedIcon: React.FunctionComponent<CustomIconComponentProps> = props => {
export const OutlinedIcon: React.FC<CustomIconComponentProps> = props => {
const path =
'M864 64H160C107 64 64 107 64 160v7' +
'04c0 53 43 96 96 96h704c53 0 96-43 96-96V160c' +
Expand All @@ -38,7 +38,7 @@ export const OutlinedIcon: React.FunctionComponent<CustomIconComponentProps> = p
);
};

export const TwoToneIcon: React.FunctionComponent<CustomIconComponentProps> = props => {
export const TwoToneIcon: React.FC<CustomIconComponentProps> = props => {
const path =
'M16 512c0 273.932 222.066 496 496 49' +
'6s496-222.068 496-496S785.932 16 512 16 16 238.' +
Expand Down
2 changes: 1 addition & 1 deletion typings/custom-typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
declare module '*.svg' {
import * as React from 'react';

export const ReactComponent: React.FunctionComponent<React.SVGProps<SVGSVGElement>>;
export const ReactComponent: React.FC<React.SVGProps<SVGSVGElement>>;

const src: string;
export default src;
Expand Down

0 comments on commit 9eee0ef

Please sign in to comment.