Skip to content

Commit 7d4995b

Browse files
authored
chore: rm defaultProps (#249)
1 parent d388cf0 commit 7d4995b

File tree

3 files changed

+45
-37
lines changed

3 files changed

+45
-37
lines changed

src/Circle.tsx

+24-19
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,27 @@ const getCircleStyle = (
6262
};
6363
};
6464

65-
const Circle: React.FC<ProgressProps> = ({
66-
id,
67-
prefixCls,
68-
steps,
69-
strokeWidth,
70-
trailWidth,
71-
gapDegree = 0,
72-
gapPosition,
73-
trailColor,
74-
strokeLinecap,
75-
style,
76-
className,
77-
strokeColor,
78-
percent,
79-
...restProps
80-
}) => {
65+
const Circle: React.FC<ProgressProps> = (props) => {
66+
const {
67+
id,
68+
prefixCls,
69+
steps,
70+
strokeWidth,
71+
trailWidth,
72+
gapDegree = 0,
73+
gapPosition,
74+
trailColor,
75+
strokeLinecap,
76+
style,
77+
className,
78+
strokeColor,
79+
percent,
80+
...restProps
81+
} = {
82+
...defaultProps,
83+
...props,
84+
};
85+
8186
const mergedId = useId(id);
8287
const gradientId = `${mergedId}-gradient`;
8388
const radius = VIEW_BOX_SIZE / 2 - strokeWidth / 2;
@@ -233,8 +238,8 @@ const Circle: React.FC<ProgressProps> = ({
233238
);
234239
};
235240

236-
Circle.defaultProps = defaultProps;
237-
238-
Circle.displayName = 'Circle';
241+
if (process.env.NODE_ENV !== 'production') {
242+
Circle.displayName = 'Circle';
243+
}
239244

240245
export default Circle;

src/Line.tsx

+21-16
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,24 @@ import classNames from 'classnames';
33
import { useTransitionDuration, defaultProps } from './common';
44
import type { ProgressProps } from './interface';
55

6-
const Line: React.FC<ProgressProps> = ({
7-
className,
8-
percent,
9-
prefixCls,
10-
strokeColor,
11-
strokeLinecap,
12-
strokeWidth,
13-
style,
14-
trailColor,
15-
trailWidth,
16-
transition,
17-
...restProps
18-
}) => {
6+
const Line: React.FC<ProgressProps> = (props) => {
7+
const {
8+
className,
9+
percent,
10+
prefixCls,
11+
strokeColor,
12+
strokeLinecap,
13+
strokeWidth,
14+
style,
15+
trailColor,
16+
trailWidth,
17+
transition,
18+
...restProps
19+
} = {
20+
...defaultProps,
21+
...props,
22+
};
23+
1924
// eslint-disable-next-line no-param-reassign
2025
delete restProps.gapPosition;
2126
const percentList = Array.isArray(percent) ? percent : [percent];
@@ -92,8 +97,8 @@ const Line: React.FC<ProgressProps> = ({
9297
);
9398
};
9499

95-
Line.defaultProps = defaultProps;
96-
97-
Line.displayName = 'Line';
100+
if (process.env.NODE_ENV !== 'production') {
101+
Line.displayName = 'Line';
102+
}
98103

99104
export default Line;

src/common.ts

-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ import { useRef, useEffect } from 'react';
22
import type { ProgressProps } from './interface';
33

44
export const defaultProps: Partial<ProgressProps> = {
5-
className: '',
65
percent: 0,
76
prefixCls: 'rc-progress',
87
strokeColor: '#2db7f5',
98
strokeLinecap: 'round',
109
strokeWidth: 1,
11-
style: {},
1210
trailColor: '#D9D9D9',
1311
trailWidth: 1,
1412
gapPosition: 'bottom',

0 commit comments

Comments
 (0)