From ea2f9dc5a430f1e72637bb6b431a86a50c18eefa Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Sun, 7 Apr 2024 15:21:46 +0200 Subject: [PATCH] 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 --- src/components/MangaGrid.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/MangaGrid.tsx b/src/components/MangaGrid.tsx index 85023ed1..91f501d8 100644 --- a/src/components/MangaGrid.tsx +++ b/src/components/MangaGrid.tsx @@ -283,8 +283,8 @@ export const MangaGrid: React.FC = (props) => { return () => {}; } - const resizeObserver = new ResizeObserver(() => { - const gridHeight = gridRef.current!.offsetHeight; + const resizeObserver = new ResizeObserver((entries) => { + const gridHeight = entries[0].target.clientHeight; const isScrollbarVisible = gridHeight > document.documentElement.clientHeight; if (!gridHeight) {