mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 06:28:51 +00:00
remove SnackBar component | improve Provider
This commit is contained in:
1 parent
8ec2a4769d
commit
82adc9497b
2 files changed
+5
-13
No files matched your search
@@ -1,9 +0,0 @@
|
||||
import React from 'react';
|
||||
|
||||
export const SnackBar = ({ children }) => {
|
||||
return (
|
||||
<div>
|
||||
<p>{children}</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import React, { createContext, useState, useEffect, useMemo, useCallback } from
|
||||
import Alert from './Alert';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import { Snackbar } from '@material-ui/core';
|
||||
import { ISnackbar } from '../interface/InterfaceUI';
|
||||
|
||||
const useStyles = makeStyles(() => ({
|
||||
alert: {
|
||||
@@ -28,7 +29,7 @@ function SnackbarProvider({ children }) {
|
||||
return () => clearTimeout(timer);
|
||||
}, [alertIdx])
|
||||
|
||||
const addAlert = useCallback((content) => setAlerts((alerts) => [content, ...alerts]), []);
|
||||
const addAlert = useCallback((message, type) => setAlerts((alerts) => [{message, type}, ...alerts]), []);
|
||||
|
||||
const value = useMemo(() => ({ addAlert }), [addAlert]);
|
||||
|
||||
@@ -36,10 +37,10 @@ function SnackbarProvider({ children }) {
|
||||
<SnackbarContext.Provider value={value}>
|
||||
<>
|
||||
{children}
|
||||
{alerts.map((alert) => (
|
||||
{alerts.map((alert: ISnackbar) => (
|
||||
<div className={classes.alert}>
|
||||
<Alert auto key={alert} severity="success" variant="filled">
|
||||
{alert}
|
||||
<Alert auto key={alert} severity="success" variant={alert.type}>
|
||||
{alert.message}
|
||||
</Alert>
|
||||
</div>
|
||||
))}
|
||||
|
||||
Reference in new issue
Block a user