Skip to content

Commit

Permalink
Merge pull request #63 from bennetrr/main
Browse files Browse the repository at this point in the history
fix: Toast Exception
  • Loading branch information
bennetrr authored Aug 11, 2024
2 parents d4e351d + 1553e9e commit fc21688
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
3 changes: 1 addition & 2 deletions src/frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ const App: React.FC = observer(() => {

return (
<>
<Toast ref={toast} />

<ToastProvider value={toast.current}>
<RouterProvider router={appRouter} />
</ToastProvider>

<Toast ref={toast} />
<ConfirmDialog />
<ConfirmPopup />
</>
Expand Down
10 changes: 1 addition & 9 deletions src/frontend/src/utils/ToastContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,4 @@ import { Toast } from 'primereact/toast';
const ToastContext = createContext<Toast | null>(null);
export const ToastProvider = ToastContext.Provider;

export function useToast(): Toast {
const toast = useContext(ToastContext);

if (!toast) {
throw new Error('Toast not initialized!');
}

return toast;
}
export const useToast: (() => Toast) = () => useContext(ToastContext) as Toast;

0 comments on commit fc21688

Please sign in to comment.