Skip to content

Commit c7e87a8

Browse files
committed
Revert "Revert "fix: react defaultProps warning (#363)""
This reverts commit 3335f6a.
1 parent 023b7e3 commit c7e87a8

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

src/Drawer.tsx

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,25 @@ export interface DrawerProps
1717
getContainer?: PortalProps['getContainer'];
1818
}
1919

20-
const Drawer: React.FC<DrawerProps> = props => {
20+
// Default Value.
21+
// Since spread with default value will make this all over components.
22+
// Let's maintain this in one place.
23+
const defaultProps = {
24+
open: false,
25+
prefixCls: 'rc-drawer',
26+
placement: 'right' as Placement,
27+
autoFocus: true,
28+
keyboard: true,
29+
width: 378,
30+
mask: true,
31+
maskClosable: true,
32+
};
33+
34+
const Drawer: React.FC<DrawerProps> = drawerProps => {
35+
const props = {
36+
...defaultProps,
37+
...drawerProps,
38+
};
2139
const {
2240
open,
2341
getContainer,
@@ -65,20 +83,6 @@ const Drawer: React.FC<DrawerProps> = props => {
6583
);
6684
};
6785

68-
// Default Value.
69-
// Since spread with default value will make this all over components.
70-
// Let's maintain this in one place.
71-
Drawer.defaultProps = {
72-
open: false,
73-
prefixCls: 'rc-drawer',
74-
placement: 'right',
75-
autoFocus: true,
76-
keyboard: true,
77-
width: 378,
78-
mask: true,
79-
maskClosable: true,
80-
};
81-
8286
if (process.env.NODE_ENV !== 'production') {
8387
Drawer.displayName = 'Drawer';
8488
}

0 commit comments

Comments
 (0)