diff --git a/frontend/src/pages/Settings/Notifications/components.tsx b/frontend/src/pages/Settings/Notifications/components.tsx index 8ad33ff46..2efde75e5 100644 --- a/frontend/src/pages/Settings/Notifications/components.tsx +++ b/frontend/src/pages/Settings/Notifications/components.tsx @@ -123,6 +123,7 @@ export const NotificationView: FunctionComponent = () => { const update = useUpdateArray( notificationsKey, + notifications ?? [], "name" ); diff --git a/frontend/src/pages/Settings/utilities/hooks.ts b/frontend/src/pages/Settings/utilities/hooks.ts index b5e3e1f61..3de556c71 100644 --- a/frontend/src/pages/Settings/utilities/hooks.ts +++ b/frontend/src/pages/Settings/utilities/hooks.ts @@ -82,7 +82,11 @@ export function useSettingValue( } } -export function useUpdateArray(key: string, compare: keyof T) { +export function useUpdateArray( + key: string, + current: Readonly, + compare: keyof T +) { const { setValue } = useFormActions(); const stagedValue = useStagedValues(); @@ -93,9 +97,9 @@ export function useUpdateArray(key: string, compare: keyof T) { if (key in stagedValue) { return stagedValue[key]; } else { - return []; + return current; } - }, [key, stagedValue]); + }, [key, stagedValue, current]); return useCallback( (v: T, hook?: HookType) => {