mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-02 12:09:14 +08:00
fix drawer lint
This commit is contained in:
parent
65e73c5f3b
commit
c863b2d758
@ -7,9 +7,11 @@ class DrawerTester extends React.Component {
|
||||
saveContainer = (container) => {
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
getContainer = () => {
|
||||
return this.container;
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
|
@ -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}
|
||||
|
@ -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') {
|
||||
|
Loading…
Reference in New Issue
Block a user