mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-02-11 12:04:24 +01:00
feat(client): Toast Provider to show Toasts from higher on the DOM tree (#1110)
This commit is contained in:
parent
81a90d245b
commit
5cafe0900c
5 changed files with 34 additions and 11 deletions
17
client/src/Providers/ToastContext.tsx
Normal file
17
client/src/Providers/ToastContext.tsx
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import { createContext } from 'react';
|
||||
import type { TShowToast } from '~/common';
|
||||
import { useToast } from '~/hooks';
|
||||
|
||||
type ToastContextType = {
|
||||
showToast: ({ message, severity, showIcon }: TShowToast) => void;
|
||||
};
|
||||
|
||||
export const ToastContext = createContext<ToastContextType>({
|
||||
showToast: () => ({}),
|
||||
});
|
||||
|
||||
export default function ToastProvider({ children }) {
|
||||
const { showToast } = useToast();
|
||||
|
||||
return <ToastContext.Provider value={{ showToast }}>{children}</ToastContext.Provider>;
|
||||
}
|
||||
2
client/src/Providers/index.ts
Normal file
2
client/src/Providers/index.ts
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
export { default as ToastProvider } from './ToastContext';
|
||||
export * from './ToastContext';
|
||||
Loading…
Add table
Add a link
Reference in a new issue