import React, { useState } from 'react'; | |
import { Button, Modal, Space } from 'antd'; | |
const App: React.FC = () => { | |
const [open, setOpen] = useState(false); | |
const showModal = () => { | |
setOpen(true); | |
}; | |
const handleOk = () => { | |
setOpen(false); | |
}; | |
const handleCancel = () => { | |
setOpen(false); | |
}; | |
return ( | |
<> | |
<Space> | |
<Button type="primary" onClick={showModal}> | |
Open Modal | |
</Button> | |
<Button | |
type="primary" | |
onClick={() => { | |
Modal.confirm({ | |
title: 'Confirm', | |
content: 'Bla bla ...', | |
footer: (_, { OkBtn, CancelBtn }) => ( | |
<> | |
<Button>Custom Button</Button> | |
<CancelBtn /> | |
<OkBtn /> | |
</> | |
), | |
}); | |
}} | |
> | |
Open Modal Confirm | |
</Button> | |
</Space> | |
<Modal | |
open={open} | |
title="Title" | |
onOk={handleOk} | |
onCancel={handleCancel} | |
footer={(_, { OkBtn, CancelBtn }) => ( | |
<> | |
<Button>Custom Button</Button> | |
<CancelBtn /> | |
<OkBtn /> | |
</> | |
)} | |
> | |
<p>Some contents...</p> | |
<p>Some contents...</p> | |
<p>Some contents...</p> | |
<p>Some contents...</p> | |
<p>Some contents...</p> | |
</Modal> | |
</> | |
); | |
}; | |
export default App; | |