Skip to content

Commit

Permalink
chore: rm defaultProps (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ authored Jun 6, 2023
1 parent d388cf0 commit 7d4995b
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 37 deletions.
43 changes: 24 additions & 19 deletions src/Circle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,27 @@ const getCircleStyle = (
};
};

const Circle: React.FC<ProgressProps> = ({
id,
prefixCls,
steps,
strokeWidth,
trailWidth,
gapDegree = 0,
gapPosition,
trailColor,
strokeLinecap,
style,
className,
strokeColor,
percent,
...restProps
}) => {
const Circle: React.FC<ProgressProps> = (props) => {
const {
id,
prefixCls,
steps,
strokeWidth,
trailWidth,
gapDegree = 0,
gapPosition,
trailColor,
strokeLinecap,
style,
className,
strokeColor,
percent,
...restProps
} = {
...defaultProps,
...props,
};

const mergedId = useId(id);
const gradientId = `${mergedId}-gradient`;
const radius = VIEW_BOX_SIZE / 2 - strokeWidth / 2;
Expand Down Expand Up @@ -233,8 +238,8 @@ const Circle: React.FC<ProgressProps> = ({
);
};

Circle.defaultProps = defaultProps;

Circle.displayName = 'Circle';
if (process.env.NODE_ENV !== 'production') {
Circle.displayName = 'Circle';
}

export default Circle;
37 changes: 21 additions & 16 deletions src/Line.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,24 @@ import classNames from 'classnames';
import { useTransitionDuration, defaultProps } from './common';
import type { ProgressProps } from './interface';

const Line: React.FC<ProgressProps> = ({
className,
percent,
prefixCls,
strokeColor,
strokeLinecap,
strokeWidth,
style,
trailColor,
trailWidth,
transition,
...restProps
}) => {
const Line: React.FC<ProgressProps> = (props) => {
const {
className,
percent,
prefixCls,
strokeColor,
strokeLinecap,
strokeWidth,
style,
trailColor,
trailWidth,
transition,
...restProps
} = {
...defaultProps,
...props,
};

// eslint-disable-next-line no-param-reassign
delete restProps.gapPosition;
const percentList = Array.isArray(percent) ? percent : [percent];
Expand Down Expand Up @@ -92,8 +97,8 @@ const Line: React.FC<ProgressProps> = ({
);
};

Line.defaultProps = defaultProps;

Line.displayName = 'Line';
if (process.env.NODE_ENV !== 'production') {
Line.displayName = 'Line';
}

export default Line;
2 changes: 0 additions & 2 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ import { useRef, useEffect } from 'react';
import type { ProgressProps } from './interface';

export const defaultProps: Partial<ProgressProps> = {
className: '',
percent: 0,
prefixCls: 'rc-progress',
strokeColor: '#2db7f5',
strokeLinecap: 'round',
strokeWidth: 1,
style: {},
trailColor: '#D9D9D9',
trailWidth: 1,
gapPosition: 'bottom',
Expand Down

0 comments on commit 7d4995b

Please sign in to comment.