fix drawer lint

pull/11234/head
陈帅 7 years ago
parent 65e73c5f3b
commit c863b2d758

@ -7,9 +7,11 @@ class DrawerTester extends React.Component {
saveContainer = (container) => { saveContainer = (container) => {
this.container = container; this.container = container;
} }
getContainer = () => { getContainer = () => {
return this.container; return this.container;
} }
render() { render() {
return ( return (
<div> <div>

@ -8,32 +8,39 @@ class DrawerEventTester extends React.Component {
super(props); super(props);
this.state = { visible: false }; this.state = { visible: false };
} }
componentDidMount() { componentDidMount() {
this.setState({ visible: true }); // eslint-disable-line react/no-did-mount-set-state this.setState({ visible: true }); // eslint-disable-line react/no-did-mount-set-state
} }
saveContainer = (container) => { saveContainer = (container) => {
this.container = container; this.container = container;
}; };
getContainer = () => { getContainer = () => {
return this.container; return this.container;
}; };
onClose = () => { onClose = () => {
this.setState({ this.setState({
visible: false, visible: false,
}); });
}; };
open = () => { open = () => {
this.setState({ this.setState({
visible: true, visible: true,
}); });
} }
render() { render() {
const { visible } = this.state;
return ( return (
<div> <div>
<Button onClick={this.open}>open</Button> <Button onClick={this.open}>open</Button>
<div ref={this.saveContainer} /> <div ref={this.saveContainer} />
<Drawer <Drawer
visible={this.state.visible} visible={visible}
onClose={this.onClose} onClose={this.onClose}
destroyOnClose destroyOnClose
getContainer={this.getContainer} getContainer={this.getContainer}

@ -51,12 +51,14 @@ export default class Drawer extends React.Component<
placement: PropTypes.string, placement: PropTypes.string,
onClose: PropTypes.func, onClose: PropTypes.func,
}; };
static defaultProps = { static defaultProps = {
prefixCls: 'ant-drawer', prefixCls: 'ant-drawer',
width: 256, width: 256,
closable: true, closable: true,
maskClosable: true, maskClosable: true,
}; };
close = (e: EventType) => { close = (e: EventType) => {
if (this.props.visible !== undefined) { if (this.props.visible !== undefined) {
if (this.props.onClose) { if (this.props.onClose) {
@ -65,12 +67,14 @@ export default class Drawer extends React.Component<
return; return;
} }
} }
onMaskClick = (e: EventType) => { onMaskClick = (e: EventType) => {
if (!this.props.maskClosable) { if (!this.props.maskClosable) {
return; return;
} }
this.close(e); this.close(e);
} }
renderBody = () => { renderBody = () => {
if (this.props.destroyOnClose && !this.props.visible) { if (this.props.destroyOnClose && !this.props.visible) {
return null; return null;
@ -107,6 +111,7 @@ export default class Drawer extends React.Component<
</div> </div>
); );
} }
render() { render() {
let { width, zIndex, style, ...rest } = this.props; let { width, zIndex, style, ...rest } = this.props;
if (typeof width === 'number') { if (typeof width === 'number') {

Loading…
Cancel
Save