Skip to content

Commit

Permalink
Prevent TypeError (#712)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
schroda authored Apr 7, 2024
1 parent d68d9b7 commit ea2f9dc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/MangaGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ export const MangaGrid: React.FC<IMangaGridProps> = (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) {
Expand Down

0 comments on commit ea2f9dc

Please sign in to comment.