fix: clearNotification now requires string

This commit is contained in:
asharonbaltazar
2022-12-07 11:52:51 -05:00
parent add3075439
commit 349865e6ef
3 changed files with 7 additions and 11 deletions

View File

@@ -6,7 +6,7 @@ import { Notification as NotificationType } from "./NotificationProvider";
interface NotificationProps {
notification: NotificationType;
clearNotification: (text?: string) => void;
clearNotification: (text: string) => void;
}
const Notification = ({

View File

@@ -11,7 +11,7 @@ export type Notification = {
};
type NotificationContextState = {
createNotification: ({ text, type }: Notification) => void;
createNotification: (newNotification: Notification) => void;
};
const NotificationContext = createContext<NotificationContextState>({
@@ -27,14 +27,10 @@ interface NotificationProviderProps {
const NotificationProvider = ({ children }: NotificationProviderProps) => {
const [notifications, setNotifications] = useState<Notification[]>([]);
const clearNotification = (text?: string) => {
if (text) {
return setNotifications((state) =>
state.filter((notif) => notif.text !== text)
);
}
return setNotifications([]);
const clearNotification = (text: string) => {
return setNotifications((state) =>
state.filter((notif) => notif.text !== text)
);
};
const createNotification = ({

View File

@@ -3,7 +3,7 @@ import { Notification as NotificationType } from "./NotificationProvider";
interface NoticationsProps {
notifications: NotificationType[];
clearNotification: (text?: string) => void;
clearNotification: (text: string) => void;
}
const Notifications = ({