ant-design/components/message/demo/loading.md
dingkang 34299b39ea
docs(message): use message hooks api (#35691)
* docs(message): use message hooks api

* docs(message): 保留一个静态方法调用

* docs: move docs demo order
2022-05-26 09:53:08 +08:00

775 B
Raw Blame History

order title
3
zh-CN en-US
加载中 Message with loading indicator

zh-CN

进行全局 loading异步自行移除。

en-US

Display a global loading indicator, which is dismissed by itself asynchronously.

import { Button, message } from 'antd';
import React from 'react';

const App: React.FC = () => {
  const [messageApi, contextHolder] = message.useMessage();

  const success = () => {
    messageApi.open({
      type: 'loading',
      content: 'Action in progress..',
      duration: 0,
    });
    // Dismiss manually and asynchronously
    setTimeout(messageApi.destroy, 2500);
  };
  return (
    <>
      {contextHolder}
      <Button onClick={success}>Display a loading indicator</Button>
    </>
  );
};

export default App;