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

37 lines
630 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
2020-01-22 12:11:49 +08:00
import React, { useState } from 'react';
import { Alert } from 'antd';
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>
);
};
2019-05-07 14:57:32 +08:00
ReactDOM.render(<App />, mountNode);
```