mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-23 23:18:36 +08:00
43 lines
949 B
TypeScript
43 lines
949 B
TypeScript
|
import React from 'react';
|
||
|
import { Button, Modal } from 'antd';
|
||
|
|
||
|
const App: React.FC = () => {
|
||
|
const [open, setOpen] = React.useState<boolean>(false);
|
||
|
const [loading, setLoading] = React.useState<boolean>(true);
|
||
|
|
||
|
const showLoading = () => {
|
||
|
setOpen(true);
|
||
|
setLoading(true);
|
||
|
|
||
|
// Simple loading mock. You should add cleanup logic in real world.
|
||
|
setTimeout(() => {
|
||
|
setLoading(false);
|
||
|
}, 2000);
|
||
|
};
|
||
|
|
||
|
return (
|
||
|
<>
|
||
|
<Button type="primary" onClick={showLoading}>
|
||
|
Open Modal
|
||
|
</Button>
|
||
|
<Modal
|
||
|
title={<p>Loading Modal</p>}
|
||
|
footer={
|
||
|
<Button type="primary" onClick={showLoading}>
|
||
|
Reload
|
||
|
</Button>
|
||
|
}
|
||
|
loading={loading}
|
||
|
open={open}
|
||
|
onCancel={() => setOpen(false)}
|
||
|
>
|
||
|
<p>Some contents...</p>
|
||
|
<p>Some contents...</p>
|
||
|
<p>Some contents...</p>
|
||
|
</Modal>
|
||
|
</>
|
||
|
);
|
||
|
};
|
||
|
|
||
|
export default App;
|