Always use "useShallow" for store selection

This commit is contained in:
schroda
2025-09-21 00:28:38 +02:00
parent 5730690ae6
commit ed488f76dd
24 changed files with 85 additions and 86 deletions

View File

@@ -63,7 +63,7 @@ const DEFAULT_STATE = {
},
} satisfies Pick<ReaderStore, 'manga'> & { scrollbar: Pick<ReaderStore['scrollbar'], 'xSize' | 'ySize'> };
export const useReaderStore = create<ReaderStore>()(
const readerStore = create<ReaderStore>()(
immer((set, get, store) => ({
...DEFAULT_STATE,
reset: () =>
@@ -114,6 +114,5 @@ export const useReaderStore = create<ReaderStore>()(
...createReaderTapZoneStoreSlice(set, get, store),
})),
);
export const useReaderStoreShallow = <T>(selector: (state: ReaderStore) => T): T =>
useReaderStore(useShallow(selector));
export const getReaderStore = () => useReaderStore.getState();
export const useReaderStore = <T>(selector: (state: ReaderStore) => T): T => readerStore(useShallow(selector));
export const getReaderStore = () => readerStore.getState();