Prevent TypeError (#712)

Somehow the grid ref was undefined after the resize observer was already connected.
This should not be possible, so just disconnect the observer in case this still happens
This commit is contained in:
schroda
2024-04-07 15:21:46 +02:00
committed by GitHub
parent d68d9b7ed2
commit ea2f9dc5a4

View File

@@ -283,8 +283,8 @@ export const MangaGrid: React.FC<IMangaGridProps> = (props) => {
return () => {}; return () => {};
} }
const resizeObserver = new ResizeObserver(() => { const resizeObserver = new ResizeObserver((entries) => {
const gridHeight = gridRef.current!.offsetHeight; const gridHeight = entries[0].target.clientHeight;
const isScrollbarVisible = gridHeight > document.documentElement.clientHeight; const isScrollbarVisible = gridHeight > document.documentElement.clientHeight;
if (!gridHeight) { if (!gridHeight) {