refactor: Change type to ensure notifs within state are Required<>

This commit is contained in:
asharonbaltazar
2022-12-07 11:58:17 -05:00
parent 251426b559
commit 9098bdc751
3 changed files with 6 additions and 4 deletions
@@ -25,7 +25,9 @@ interface NotificationProviderProps {
}
const NotificationProvider = ({ children }: NotificationProviderProps) => {
const [notifications, setNotifications] = useState<Notification[]>([]);
const [notifications, setNotifications] = useState<Required<Notification>[]>(
[]
);
const clearNotification = (text: string) => {
return setNotifications((state) =>
@@ -44,7 +46,7 @@ const NotificationProvider = ({ children }: NotificationProviderProps) => {
return;
}
const newNotification: Notification = { text, type, timeoutMs };
const newNotification: Required<Notification> = { text, type, timeoutMs };
return setNotifications((state) => [...state, newNotification]);
};