mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-25 16:58:00 +08:00
35 lines
672 B
TypeScript
35 lines
672 B
TypeScript
|
import React from 'react';
|
||
|
import { Button, notification } from 'antd';
|
||
|
|
||
|
const key = 'updatable';
|
||
|
|
||
|
const App: React.FC = () => {
|
||
|
const [api, contextHolder] = notification.useNotification();
|
||
|
const openNotification = () => {
|
||
|
api.open({
|
||
|
key,
|
||
|
message: 'Notification Title',
|
||
|
description: 'description.',
|
||
|
});
|
||
|
|
||
|
setTimeout(() => {
|
||
|
api.open({
|
||
|
key,
|
||
|
message: 'New Title',
|
||
|
description: 'New description.',
|
||
|
});
|
||
|
}, 1000);
|
||
|
};
|
||
|
|
||
|
return (
|
||
|
<>
|
||
|
{contextHolder}
|
||
|
<Button type="primary" onClick={openNotification}>
|
||
|
Open the notification box
|
||
|
</Button>
|
||
|
</>
|
||
|
);
|
||
|
};
|
||
|
|
||
|
export default App;
|