mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-21 13:18:04 +08:00
31 lines
962 B
TypeScript
31 lines
962 B
TypeScript
|
import React from 'react';
|
||
|
import { Button, notification, Space } from 'antd';
|
||
|
|
||
|
type NotificationType = 'success' | 'info' | 'warning' | 'error';
|
||
|
|
||
|
const App: React.FC = () => {
|
||
|
const [api, contextHolder] = notification.useNotification();
|
||
|
|
||
|
const openNotificationWithIcon = (type: NotificationType) => {
|
||
|
api[type]({
|
||
|
message: 'Notification Title',
|
||
|
description:
|
||
|
'This is the content of the notification. This is the content of the notification. This is the content of the notification.',
|
||
|
});
|
||
|
};
|
||
|
|
||
|
return (
|
||
|
<>
|
||
|
{contextHolder}
|
||
|
<Space>
|
||
|
<Button onClick={() => openNotificationWithIcon('success')}>Success</Button>
|
||
|
<Button onClick={() => openNotificationWithIcon('info')}>Info</Button>
|
||
|
<Button onClick={() => openNotificationWithIcon('warning')}>Warning</Button>
|
||
|
<Button onClick={() => openNotificationWithIcon('error')}>Error</Button>
|
||
|
</Space>
|
||
|
</>
|
||
|
);
|
||
|
};
|
||
|
|
||
|
export default App;
|