-
-
Notifications
You must be signed in to change notification settings - Fork 193
/
Copy pathmultiple-Portal.tsx
65 lines (60 loc) · 1.39 KB
/
multiple-Portal.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import * as React from 'react';
import Drawer from 'rc-drawer';
import 'rc-drawer/assets/index.css';
import Dialog from 'rc-dialog';
import '../../assets/index.less';
const Demo: React.FC = () => {
const [showDialog, setShowDialog] = React.useState(false);
const [showDrawer, setShowDrawer] = React.useState(false);
const onToggleDrawer = () => {
setShowDrawer((value) => !value);
};
const onToggleDialog = () => {
setShowDialog((value) => !value);
};
const dialog = (
<Dialog
visible={showDialog}
animation="zoom"
maskAnimation="fade"
onClose={onToggleDialog}
forceRender
title="basic modal"
>
<p>
<button type="button" onClick={onToggleDrawer}>
show drawer
</button>
</p>
<div style={{ height: 200 }} />
</Dialog>
);
const drawer = (
<Drawer open={showDrawer} onClose={onToggleDrawer}>
<button type="button" onClick={onToggleDrawer}>
close drawer
</button>
</Drawer>
);
return (
<div>
<button type="button" onClick={onToggleDialog}>
open dialog
</button>
<button
type="button"
onClick={() => {
setShowDialog(true);
setTimeout(() => {
setShowDialog(false);
}, 0);
}}
>
quick
</button>
{dialog}
{drawer}
</div>
);
};
export default Demo;