mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
refactor: Directly use Ant Design's notification hook instead of App.useApp for notification management.
This commit is contained in:
parent
eee37c569d
commit
a48a8ec945
1 changed files with 8 additions and 13 deletions
|
|
@ -1,29 +1,24 @@
|
|||
"use client";
|
||||
|
||||
import React, { useEffect, useRef } from "react";
|
||||
import { App } from "antd";
|
||||
import { notification } from "antd";
|
||||
import { setNotificationInstance } from "@/components/molecules/notifications_manager";
|
||||
|
||||
// Inner component to use the hook
|
||||
const AntdAppInit = () => {
|
||||
const { notification } = App.useApp();
|
||||
export default function AntdGlobalProvider({ children }: { children: React.ReactNode }) {
|
||||
const [api, contextHolder] = notification.useNotification();
|
||||
const initialized = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!initialized.current) {
|
||||
setNotificationInstance(notification);
|
||||
setNotificationInstance(api);
|
||||
initialized.current = true;
|
||||
}
|
||||
}, [notification]);
|
||||
}, [api]);
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
export default function AntdGlobalProvider({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<App>
|
||||
<AntdAppInit />
|
||||
<>
|
||||
{contextHolder}
|
||||
{children}
|
||||
</App>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue