ant-design/components/message/demo/thenable.md
MadCcc 6776bb8916
docs: demo support react18 (#34843)
* docs: update demo

* chore: add script

* test: fix demo test

* docs: convert demos

* chore: move script

* test: remove react-dom import

* chore: update deps

* docs: update riddle js

* test: fix image test

* docs: fix riddle demo
2022-04-03 23:27:45 +08:00

28 lines
720 B
Markdown

---
order: 5
title:
zh-CN: Promise 接口
en-US: Promise interface
---
## zh-CN
可以通过 then 接口在关闭后运行 callback 。以上用例将在每个 message 将要结束时通过 then 显示新的 message 。
## en-US
`message` provides a promise interface for `onClose`. The above example will display a new message when the old message is about to close.
```jsx
import { message, Button } from 'antd';
const success = () => {
message
.loading('Action in progress..', 2.5)
.then(() => message.success('Loading finished', 2.5))
.then(() => message.info('Loading finished is finished', 2.5));
};
export default () => <Button onClick={success}>Display sequential messages</Button>;
```