ant-design/components/alert/demo/smooth-closed.md

39 lines
615 B
Markdown
Raw Normal View History

---
order: 7
title:
zh-CN: 平滑地卸载
en-US: Smoothly Unmount
---
## zh-CN
2018-09-16 18:36:17 +08:00
平滑、自然的卸载提示。
## en-US
2019-04-19 20:48:29 +08:00
Smoothly unmount Alert upon close.
2020-01-21 16:21:37 +08:00
```tsx
import { Alert } from 'antd';
2022-05-23 14:37:16 +08:00
import React, { useState } from 'react';
2020-01-21 17:14:58 +08:00
const App: React.FC = () => {
2020-01-22 12:11:49 +08:00
const [visible, setVisible] = useState(true);
2020-01-21 16:21:37 +08:00
const handleClose = () => {
setVisible(false);
2019-05-07 14:57:32 +08:00
};
2020-01-21 16:21:37 +08:00
return (
<div>
{visible ? (
<Alert message="Alert Message Text" type="success" closable afterClose={handleClose} />
) : null}
<p>placeholder text here</p>
</div>
);
};
export default App;
2019-05-07 14:57:32 +08:00
```