fix drawer lint

This commit is contained in:
陈帅 2018-06-26 00:22:50 +08:00
parent 65e73c5f3b
commit c863b2d758
3 changed files with 15 additions and 1 deletions

View File

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

View File

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

View File

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