Improve "page load state" updates
Changes of d6ff85fdd3 decreased the render performance due to the "onLoad" function changing and causing all pages to re-render.
This commit is contained in:
@@ -192,9 +192,15 @@ const BaseReaderViewer = forwardRef(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setPageLoadStates((statePageLoadStates) => statePageLoadStates.toSpliced(index, 1, { loaded: true }));
|
setPageLoadStates((statePageLoadStates) => {
|
||||||
|
if (statePageLoadStates[index].loaded) {
|
||||||
|
return statePageLoadStates;
|
||||||
|
}
|
||||||
|
|
||||||
|
return statePageLoadStates.toSpliced(index, 1, { loaded: true });
|
||||||
|
});
|
||||||
},
|
},
|
||||||
[actualPages, readingMode, pageLoadStates],
|
[actualPages, readingMode],
|
||||||
);
|
);
|
||||||
|
|
||||||
const onError = useCallback((pageIndex: number) => {
|
const onError = useCallback((pageIndex: number) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user