frontend / context/toast/ToastContext
context/toast/ToastContext
File
ToastContext.ts
Enterprise
- Provides a simple callback interface for toast notifications
- Used by both authenticated (AppShell) and unauthenticated (AppPublicShell) shells
- Consumed by page components and dialogs via useToast() hook
- No-op default context to prevent errors if used outside provider
- Type-safe severity levels matching MUI Alert component
Example
// In a shell:
<ToastContext.Provider value={(msg, severity) => showToast(msg, severity)}>
{children}
</ToastContext.Provider>
// In a component:
const toast = useToast();
toast('Operation successful', 'success');