From fcf1c7fa3f9f0ea9710bc547ac41cab7d97156fc Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Fri, 20 Mar 2026 03:01:32 +0100 Subject: [PATCH] Fix "Maximum update depth exceeded" Regression b63c8a548e423fc3693cfcd05b76fc1fb3420e3f --- src/base/Base.constants.ts | 11 +++++++++++ src/base/collection/hooks/useSelectableCollection.ts | 5 +++-- 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 src/base/Base.constants.ts diff --git a/src/base/Base.constants.ts b/src/base/Base.constants.ts new file mode 100644 index 00000000..68e2d985 --- /dev/null +++ b/src/base/Base.constants.ts @@ -0,0 +1,11 @@ +/* + * Copyright (C) Contributors to the Suwayomi project + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +export const STABLE_EMPTY_OBJECT = Object.freeze({}) as never; + +export const STABLE_EMPTY_ARRAY = Object.freeze([]) as never[]; diff --git a/src/base/collection/hooks/useSelectableCollection.ts b/src/base/collection/hooks/useSelectableCollection.ts index e9d9eab6..05badab9 100644 --- a/src/base/collection/hooks/useSelectableCollection.ts +++ b/src/base/collection/hooks/useSelectableCollection.ts @@ -7,6 +7,7 @@ */ import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; +import { STABLE_EMPTY_ARRAY, STABLE_EMPTY_OBJECT } from '@/base/Base.constants.ts'; export type SelectableCollectionReturnType = { selectedItemIds: Id[]; @@ -26,10 +27,10 @@ export type SelectableCollectionReturnType( totalCount: number, { - itemIds = [], + itemIds = STABLE_EMPTY_ARRAY, keyCount = totalCount, currentKey, - initialState = {} as Record, + initialState = STABLE_EMPTY_OBJECT, }: { itemIds?: Id[]; keyCount?: number;