Remove context usage from ReaderChapterViewer

In case many chapters are rendered, even just the HOC wrapper component re-render due to the context change increases the render time.

Thus, getting rid of these HOC wrapper re-renders by moving the context usage up to the ReaderViewer decreases the render time.
This commit is contained in:
schroda
2025-02-03 15:10:13 +01:00
parent 4a9d2903b8
commit b01b23b069
9 changed files with 43 additions and 52 deletions

View File

@@ -8,11 +8,9 @@
import { memo, ReactNode, useCallback, useEffect, useMemo, useRef } from 'react';
import Box, { BoxProps } from '@mui/material/Box';
import { ReaderService } from '@/modules/reader/services/ReaderService.ts';
import { getPageIndexesToLoad, isATransitionPageVisible } from '@/modules/reader/utils/ReaderPager.utils.tsx';
import { ReaderStatePages } from '@/modules/reader/types/ReaderProgressBar.types.ts';
import { IReaderSettings, ReaderPagerProps, ReaderTransitionPageMode } from '@/modules/reader/types/Reader.types.ts';
import { withPropsFrom } from '@/modules/core/hoc/withPropsFrom.tsx';
import { applyStyles } from '@/modules/core/utils/ApplyStyles.ts';
import { isContinuousReadingMode } from '@/modules/reader/utils/ReaderSettings.utils.tsx';
@@ -101,8 +99,4 @@ const BaseBasePager = ({
);
};
export const BasePager = withPropsFrom(
memo(BaseBasePager),
[ReaderService.useSettingsWithoutDefaultFlag],
['readingMode', 'imagePreLoadAmount'],
);
export const BasePager = memo(BaseBasePager);