mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-11 23:00:20 +08:00
42 lines
870 B
TypeScript
42 lines
870 B
TypeScript
|
import React, { useState } from 'react';
|
||
|
import { Button, Popconfirm } from 'antd';
|
||
|
|
||
|
const App: React.FC = () => {
|
||
|
const [open, setOpen] = useState(false);
|
||
|
const [confirmLoading, setConfirmLoading] = useState(false);
|
||
|
|
||
|
const showPopconfirm = () => {
|
||
|
setOpen(true);
|
||
|
};
|
||
|
|
||
|
const handleOk = () => {
|
||
|
setConfirmLoading(true);
|
||
|
|
||
|
setTimeout(() => {
|
||
|
setOpen(false);
|
||
|
setConfirmLoading(false);
|
||
|
}, 2000);
|
||
|
};
|
||
|
|
||
|
const handleCancel = () => {
|
||
|
console.log('Clicked cancel button');
|
||
|
setOpen(false);
|
||
|
};
|
||
|
|
||
|
return (
|
||
|
<Popconfirm
|
||
|
title="Title"
|
||
|
open={open}
|
||
|
onConfirm={handleOk}
|
||
|
okButtonProps={{ loading: confirmLoading }}
|
||
|
onCancel={handleCancel}
|
||
|
>
|
||
|
<Button type="primary" onClick={showPopconfirm}>
|
||
|
Open Popconfirm with async logic
|
||
|
</Button>
|
||
|
</Popconfirm>
|
||
|
);
|
||
|
};
|
||
|
|
||
|
export default App;
|