Skip to content

Commit bbb2aa1

Browse files
authored
Merge pull request #23 from DrZanuff/refactor/RemoveDeafultPropsWarning
refactor: remove defaultprops warning
2 parents c7936af + 094becb commit bbb2aa1

10 files changed

+37
-53
lines changed

src/SpinnerCircular.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import './SpinnerCircular.css';
77
export type SpinnerCircularProps = SpinnersProps & SecondaryColorSpinnerProps;
88

99
const Component = ({
10-
secondaryColor,
11-
speed,
12-
still,
13-
thickness,
10+
secondaryColor = secondaryColorDefaultProps.secondaryColor,
11+
speed = secondaryColorDefaultProps.speed,
12+
still = secondaryColorDefaultProps.still,
13+
thickness = secondaryColorDefaultProps.thickness,
1414
...svgProps
1515
}: SecondaryColorSpinnerProps) => {
1616
const strokeWidth = 4 * (thickness / 100);
@@ -44,6 +44,4 @@ const Component = ({
4444
);
4545
};
4646

47-
Component.defaultProps = secondaryColorDefaultProps;
48-
4947
export const SpinnerCircular = withSharedProps(Component);

src/SpinnerCircularFixed.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import './SpinnerCircularFixed.css';
77
export type SpinnerCircularFixedProps = SpinnersProps & SecondaryColorSpinnerProps;
88

99
const Component = ({
10-
secondaryColor,
11-
speed,
12-
still,
13-
thickness,
10+
secondaryColor = secondaryColorDefaultProps.secondaryColor,
11+
speed = secondaryColorDefaultProps.speed,
12+
still = secondaryColorDefaultProps.still,
13+
thickness = secondaryColorDefaultProps.thickness,
1414
...svgProps
1515
}: SecondaryColorSpinnerProps) => {
1616
const strokeWidth = 4 * (thickness / 100);
@@ -44,6 +44,4 @@ const Component = ({
4444
);
4545
};
4646

47-
Component.defaultProps = secondaryColorDefaultProps;
48-
4947
export const SpinnerCircularFixed = withSharedProps(Component);

src/SpinnerCircularSplit.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import './SpinnerCircularSplit.css';
77
export type SpinnerCircularSplitProps = SpinnersProps & SecondaryColorSpinnerProps;
88

99
const Component = ({
10-
secondaryColor,
11-
speed,
12-
still,
13-
thickness,
10+
secondaryColor = secondaryColorDefaultProps.secondaryColor,
11+
speed = secondaryColorDefaultProps.speed,
12+
still = secondaryColorDefaultProps.still,
13+
thickness = secondaryColorDefaultProps.thickness,
1414
...svgProps
1515
}: SecondaryColorSpinnerProps) => {
1616
const strokeWidth = 4 * (thickness / 100);
@@ -45,6 +45,4 @@ const Component = ({
4545
);
4646
};
4747

48-
Component.defaultProps = secondaryColorDefaultProps;
49-
5048
export const SpinnerCircularSplit = withSharedProps(Component);

src/SpinnerDiamond.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ const coords = [
3636
export type SpinnerDiamondProps = SpinnersProps & SecondaryColorSpinnerProps;
3737

3838
const Component = ({
39-
secondaryColor,
40-
speed,
41-
still,
42-
thickness,
39+
secondaryColor = secondaryColorDefaultProps.secondaryColor,
40+
speed = secondaryColorDefaultProps.speed,
41+
still = secondaryColorDefaultProps.still,
42+
thickness = secondaryColorDefaultProps.thickness,
4343
...svgProps
4444
}: SecondaryColorSpinnerProps) => {
4545
const diamondStyle: CSSProperties = {
@@ -62,7 +62,5 @@ const Component = ({
6262
);
6363
};
6464

65-
Component.defaultProps = secondaryColorDefaultProps;
66-
6765
export const SpinnerRomb = withSharedProps(Component);
6866
export const SpinnerDiamond = withSharedProps(Component);

src/SpinnerDotted.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ const coords = [
1818
export type SpinnerDottedProps = SpinnersProps & SpinnerProps;
1919

2020
export const Component = ({
21-
speed,
22-
still,
23-
thickness,
21+
speed = defaultProps.speed,
22+
still = defaultProps.still,
23+
thickness = defaultProps.thickness,
2424
...svgProps
2525
}: SpinnerProps) => {
2626
const duration = 200 / speed;
@@ -60,6 +60,4 @@ export const Component = ({
6060
);
6161
};
6262

63-
Component.defaultProps = defaultProps;
64-
6563
export const SpinnerDotted = withSharedProps(Component);

src/SpinnerInfinity.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import './SpinnerInfinity.css';
77
export type SpinnerInfinityProps = SpinnersProps & SecondaryColorSpinnerProps;
88

99
const Component = ({
10-
secondaryColor,
11-
speed,
12-
still,
13-
thickness,
10+
secondaryColor = secondaryColorDefaultProps.secondaryColor,
11+
speed = secondaryColorDefaultProps.speed,
12+
still = secondaryColorDefaultProps.still,
13+
thickness = secondaryColorDefaultProps.thickness,
1414
...svgProps
1515
}: SecondaryColorSpinnerProps) => {
1616
const strokeWidth = 7 * (thickness / 100);
@@ -41,6 +41,4 @@ const Component = ({
4141
);
4242
};
4343

44-
Component.defaultProps = secondaryColorDefaultProps;
45-
4644
export const SpinnerInfinity = withSharedProps(Component);

src/SpinnerRound.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import './SpinnerRound.css';
77
export type SpinnerRoundProps = SpinnersProps & SpinnerProps;
88

99
const Component = ({
10-
speed,
11-
still,
12-
thickness,
10+
speed = defaultProps.speed,
11+
still = defaultProps.still,
12+
thickness = defaultProps.thickness,
1313
...svgProps
1414
}: SpinnerProps) => {
1515
const strokeWidth = 3 * (thickness / 100);
@@ -35,6 +35,4 @@ const Component = ({
3535
);
3636
};
3737

38-
Component.defaultProps = defaultProps;
39-
4038
export const SpinnerRound = withSharedProps(Component);

src/SpinnerRoundFilled.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ const animations = [
2323
export type SpinnerRoundFilledProps = SpinnersProps & SpinnerProps;
2424

2525
const Component = ({
26-
speed,
27-
still,
28-
thickness,
26+
speed = defaultProps.speed,
27+
still = defaultProps.still,
28+
thickness = defaultProps.thickness,
2929
...svgProps
3030
}: SpinnerProps) => (
3131
<svg fill="none" {...svgProps} viewBox="0 0 66 66">
@@ -48,6 +48,4 @@ const Component = ({
4848
</svg>
4949
);
5050

51-
Component.defaultProps = defaultProps;
52-
5351
export const SpinnerRoundFilled = withSharedProps(Component);

src/SpinnerRoundOutlined.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ const animations = [
2121
export type SpinnerRoundOutlinedProps = SpinnersProps & SpinnerProps;
2222

2323
const Component = ({
24-
speed,
25-
still,
26-
thickness,
24+
speed = defaultProps.speed,
25+
still = defaultProps.still,
26+
thickness = defaultProps.thickness,
2727
...svgProps
2828
}: SpinnerProps) => {
2929
const strokeWidth = 3 * (thickness / 100);
@@ -48,6 +48,4 @@ const Component = ({
4848
);
4949
};
5050

51-
Component.defaultProps = defaultProps;
52-
5351
export const SpinnerRoundOutlined = withSharedProps(Component);

src/withSharedProps.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ export type SpinnersProps = Partial<typeof defaultProps>;
1717
export const withSharedProps = <P extends SpinnersProps>(Component: ComponentType<P>) => {
1818
const Wrapper = (props: P) => {
1919
const {
20-
color, enabled, size, style, ...otherProps
20+
color = defaultProps.color,
21+
enabled = defaultProps.enabled,
22+
size = defaultProps.size,
23+
style = defaultProps.style,
24+
...otherProps
2125
} = props;
2226
const componentProps = {
2327
...otherProps,
@@ -34,7 +38,5 @@ export const withSharedProps = <P extends SpinnersProps>(Component: ComponentTyp
3438
return <Component {...componentProps as P} />;
3539
};
3640

37-
Wrapper.defaultProps = defaultProps;
38-
3941
return Wrapper;
4042
};

0 commit comments

Comments
 (0)