Skip to content

Commit

Permalink
feat: refactor alerts provider
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpastor committed Jun 26, 2023
1 parent 2a0862c commit 3fc8c7e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/configs/providers/alerts-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface IAlertsContext {
}

export const AlertsContext = createContext<IAlertsContext | undefined>(undefined);
AlertsContext.displayName = "AlertsContext";

const LazySnackbar = dynamic((): Promise<{ default: ComponentType<SnackbarProps> }> => (
import("@mui/material/Snackbar")
Expand Down Expand Up @@ -86,8 +87,8 @@ export const AlertsProvider = ({ children }: PropsWithChildren<unknown>): ReactE
enqueueErrorAlert
}), [enqueueErrorAlert, enqueueSuccessAlert, enqueueWarningAlert]);

// TODO Look into why Alert can't be lazy loaded
return (
// TODO Investigate if the context provider can be moved in its own component.
<AlertsContext.Provider value={value}>
<Suspense>
<LazySnackbar
Expand All @@ -96,6 +97,7 @@ export const AlertsProvider = ({ children }: PropsWithChildren<unknown>): ReactE
TransitionProps={{ onExited: handleExited }}
autoHideDuration={5000}
>
{/** TODO Look into why Alert can't be lazy loaded */}
<MuiAlert severity={alerts[0]?.severity}>
{alerts[0]?.message}
</MuiAlert>
Expand Down

1 comment on commit 3fc8c7e

@vercel
Copy link

@vercel vercel bot commented on 3fc8c7e Jun 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.