diff --git a/src/Drawer.tsx b/src/Drawer.tsx index e676158..7e00da5 100644 --- a/src/Drawer.tsx +++ b/src/Drawer.tsx @@ -17,7 +17,25 @@ export interface DrawerProps getContainer?: PortalProps['getContainer']; } -const Drawer: React.FC = props => { +// Default Value. +// Since spread with default value will make this all over components. +// Let's maintain this in one place. +const defaultProps = { + open: false, + prefixCls: 'rc-drawer', + placement: 'right' as Placement, + autoFocus: true, + keyboard: true, + width: 378, + mask: true, + maskClosable: true, +}; + +const Drawer: React.FC = drawerProps => { + const props = { + ...defaultProps, + ...drawerProps, + }; const { open, getContainer, @@ -65,20 +83,6 @@ const Drawer: React.FC = props => { ); }; -// Default Value. -// Since spread with default value will make this all over components. -// Let's maintain this in one place. -Drawer.defaultProps = { - open: false, - prefixCls: 'rc-drawer', - placement: 'right', - autoFocus: true, - keyboard: true, - width: 378, - mask: true, - maskClosable: true, -}; - if (process.env.NODE_ENV !== 'production') { Drawer.displayName = 'Drawer'; }